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

            Bug ID: 129160
           Summary: Missed if-conversion
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: law at gcc dot gnu.org
  Target Milestone: ---

I'm a bit surprised we don't have a bug for this, but I wandered a bit and
didn't see one.  Consider this (derived from x264)

long
f (long c, long a, long b, long *p)
{
  long s = a + b;
  long r = c ? s : a;
  *p = s;
  return r;
}

Conceptually we can select across 0/b and unconditionally add that to a.  But
instead select across a + b and a.  Ugh.

        add     a2,a1,a2        # 10    [c=4 l=4]  *adddi3/0
        czero.eqz       a5,a2,a0        # 31    [c=4 l=4]  *czero.eqz.didi
        czero.nez       a0,a1,a0        # 30    [c=4 l=4]  *czero.nez.didi
        sd      a2,0(a3)        # 15    [c=4 l=4]  *movdi_64bit/3
        add     a0,a5,a0        # 20    [c=4 l=4]  *adddi3/0
        ret             # 46    [c=0 l=4]  simple_return

Reply via email to