Bug 93616 - Missed chance to use alias checks to vectorise invariant indirection
Summary: Missed chance to use alias checks to vectorise invariant indirection
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 10.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: alias, missed-optimization
Depends on:
Blocks: vectorizer
  Show dependency treegraph
 
Reported: 2020-02-06 16:07 UTC by Richard Sandiford
Modified: 2020-02-07 07:48 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-02-06 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Richard Sandiford 2020-02-06 16:07:50 UTC
For:

void
foo (char **dest_ptr, char *src)
{
  for (int i = 0; i < 100; ++i)
    (*dest_ptr)[i] = src[i];
}

we should be able to emit a runtime alias check that [src, src+99]
doesn't overlap *dest_ptr and then vectorise the loop normally.
Comment 1 Martin Sebor 2020-02-06 21:30:35 UTC
For the cases when the overlap is exceedingly unlikely it would be helpful to issue a warning suggesting to qualify the function arguments with the restrict keyword.  That would make it possible to avoid the runtime check.
Comment 2 Andrew Pinski 2020-02-06 21:32:31 UTC
Confirmed.
Comment 3 Richard Biener 2020-02-07 07:48:54 UTC
I think the issue is (*dest_ptr)[i] overlapping (*dest_ptr), 'src' doesn't even come into play here.