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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
                 CC|                            |rguenth at gcc dot gnu.org
   Last reconfirmed|                            |2025-05-20
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
int f1(type *b)
{
  type a = *b;
  *b = a - 24;
  if (*b == 1)
    return g();
  return 0;
}

is similarly "bad".  This is about us not realizing it's worth canonicalizing
compares to ==/!= 0, aka reduce them to the various CCmode tests.

For 'f' it could work to pattern-match SSA == CST in FRE and see whether
there's SSA - CST available and then re-write as == 0.  Of course folding
would immediately undo that unless restricted by single-use (but after CSE
it should have multiple uses).

I don't think this is a target thing.  I'm not sure it's easily possible
to handle this on the RTL side (in CSE, again), it might be detrimental
before combine.

Reply via email to