https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106615
Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2022-08-14
             Status|UNCONFIRMED                 |NEW
           Severity|normal                      |enhancement

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Reduced testcase:
int g_44;

void func_16(int *a, unsigned long int b) {
        *a = 5;
        if ((g_44 = 1) <= b)
                ;
        else
                *a = 0;
}

---- CUT ----
So CSElim on the gimple level goes from:

  *a_3(D) = 5;
  g_44 = 1;
  if (b_6(D) != 0)
    goto <bb 4>; [50.00%]
  else
    goto <bb 3>; [50.00%]

  <bb 3> [local count: 536870913]:
  *a_3(D) = 0;

  <bb 4> [local count: 1073741824]:
  return;

to:

  *a_3(D) = 5;
  g_44 = 1;
  if (b_6(D) != 0)
    goto <bb 3>; [50.00%]
  else
    goto <bb 4>; [50.00%]

  <bb 3> [local count: 536870912]:
  cstore_8 = MEM <int> [(void *)a_3(D)];

  <bb 4> [local count: 1073741824]:
  # cstore_9 = PHI <cstore_8(3), 0(2)>
  MEM <int> [(void *)a_3(D)] = cstore_9;

Thinking it might be able to remove the load inside the if branch (for an
example at -O2 with 1 instead of 5, GCC can remove the load).
And then nothing afterwards will undo that transformation.

Reply via email to