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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-10-07
          Component|c                           |tree-optimization
            Version|unknown                     |5.2.0
         Depends on|                            |23286
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
With GCC 5 at -O2 it's

_Z1fiiPi:
.LFB0:
        .cfi_startproc
        cmpl    %esi, %edi
        movl    (%rdx), %eax
        jl      .L5
        addl    $1, %eax
        ret
        .p2align 4,,10
        .p2align 3
.L5:
        rep ret

vs.

_Z2f2iiPi:
.LFB1:
        .cfi_startproc
        xorl    %eax, %eax
        cmpl    %esi, %edi
        setge   %al
        addl    (%rdx), %eax
        ret

where f2 is already in if-converted form on the GIMPLE level:

int f2(int, int, int*) (int a, int b, int * c)
{
  int _6;
  int _7;
  bool _8;
  int _9;

  <bb 2>:
  _6 = *c_5(D);
  _8 = a_2(D) >= b_3(D);
  _9 = (int) _8;
  _7 = _6 + _9;
  return _7;

The reason why we are not if-converting f on the GIMPLE level is
the lack of a code hoisting pass and thus we have

  <bb 2>:
  if (a_2(D) < b_3(D))
    goto <bb 3>;
  else
    goto <bb 4>;

  <bb 3>:
  iftmp.0_6 = *c_5(D);
  goto <bb 5>;

  <bb 4>:
  _7 = *c_5(D);
  iftmp.0_8 = _7 + 1;

  <bb 5>:
  # iftmp.0_1 = PHI <iftmp.0_6(3), iftmp.0_8(4)>

which "confuses" phiopt enough.  Only RTL hoists the loads (in 261r.mach?).

PR23286 tracks the lack of code hoisting on GIMPLE.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23286
[Bug 23286] Missed code hoisting optimization

Reply via email to