https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116835

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #5)
> Found a testcase which we produce wrong code as we introduce an
> unconditional load:
> ```
> extern int a __attribute__((weak));
> 
> int b;
> int bar (int c) __attribute__((noipa, noinline));
> int 
> bar (int c)
> {
>   int *p = &a;
>   for (int j = 0; j < c; ++j)
>     p = &b;
>   return *p;
> }
> 
> int main(void)
> {
>  if (bar(100))
>    __builtin_abort();
> }
> ```
> 
> Compile this at -Os and you will see the load from a happens even though it
> is weak.

Or `-O1 -fno-tree-sink` since otherwise sinks the load of a into the branch.

Reply via email to