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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-08-04
             Status|UNCONFIRMED                 |NEW
   Target Milestone|---                         |12.4
     Ever confirmed|0                           |1
           Keywords|                            |needs-bisection
            Summary|[14 Regression] Dead Code   |[12/13/14 Regression] Dead
                   |Elimination Regression      |Code Elimination Regression
                   |since r14-1597-g64d90d06d2d |

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. before r14-1597, there was a jump threading happening with respect
to:
  if (j_32 <= 0)
    goto <bb 9>; [50.00%]
  else
    goto <bb 8>; [50.00%]

  <bb 8> [local count: 238907556]:

  <bb 9> [local count: 477815112]:
  # iftmp.10_37 = PHI <_11(7), 0(8)>

But after, we change that into
iftmp.10_37 = _11 & (j_32 <= 0);

It just happens we depend on that due to:
  _43 = l_22 | _25;
  _39 = j_32 <= 0;
  _12 = ~_43;
  _44 = _12 & _39;


If we change the code to be:
```
void foo(void);
static signed char b, c;
static short e, f;
static int g = 41317;
static int(a)(int h, int i) { return h + i; }
static int(d)(int h, int i) { return i & h;}//i ? h : 0; }
short t = 10;
int main() {
    {
        signed char j;
        short k = t;
        for (; g >= 10; g = (short)g) {
            _Bool l = 1;
            int m = 0;
            j = 8 * k;
            k = j <= 0;
            f = c + 3;
            for (; c < 2; c = f) {
                signed char n = 4073709551615;
                if (!(((m) >= 0) && ((m) <= 0))) {
                    __builtin_unreachable();
                }
                if (g)
                    ;
                else {
                    if ((m = k, (b = a(d(l, k), e) && n) || l) < k) foo();
                    e = l = 0;
                }
            }
        }
    }
}
```

GCC 11 is able to remove the call to foo but GCC 12 cannot.
the IR for the part where the phiopt2 changes on the trunk is similar enough.

So this is instead a regression from GCC 11.

Reply via email to