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

--- Comment #3 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Tree optimizations already manage to avoid "optimizing" f_intadd, but
unfortunately on RTL types and casts are not visible in IR and various passes
make no distinction between (char*)((uintptr_t)t + o) and (t + o).

Perhaps GCC should consider lowering pointer-to-integer casts to a
non-transparent assignment, making the result alias all for the purposes of RTL
alias analysis, akin to

char __attribute__ ((noinline)) f_intadd1(ptrdiff_t o) {
  g = 1;
  uintptr_t t1 = (uintptr_t)t;
  asm("" : "+g"(t1));
  *(char*)(t1 + o) = 2;
  return g;
}

Reply via email to