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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Target|                            |x86_64-*-*, i?86-*-*
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-11-07
          Component|tree-optimization           |target
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  For f we fail to detect the max() operation at the tree level
because the test is using != 0 instead of < 1.

f (unsigned int num)
{
  unsigned int iftmp.0_1;

  <bb 2> [local count: 1073741825]:
  if (num_2(D) != 0)
    goto <bb 4>; [50.00%]
  else
    goto <bb 3>; [50.00%]

  <bb 3> [local count: 536870913]:

  <bb 4> [local count: 1073741825]:
  # iftmp.0_1 = PHI <num_2(D)(2), 1(3)>
  return iftmp.0_1;


g is represented as

g (unsigned int num)
{
  _Bool _1;
  unsigned int _2;
  unsigned int _4;

  <bb 2> [local count: 1073741825]:
  _1 = num_3(D) == 0;
  _2 = (unsigned int) _1;
  _4 = _2 + num_3(D);
  return _4;

expanded to (after combine)

(insn 6 3 7 2 (set (reg:CCZ 17 flags)
        (compare:CCZ (reg/v:SI 85 [ num ])
            (const_int 0 [0]))) "/tmp/t.c":13:16 7 {*cmpsi_ccno_1}
     (nil))
(insn 8 7 9 2 (set (reg:SI 87)
        (eq:SI (reg:CCZ 17 flags)
            (const_int 0 [0]))) "/tmp/t.c":13:16 652 {*setcc_si_1_movzbl}
(insn 9 8 14 2 (parallel [
            (set (reg:SI 86)
                (plus:SI (reg:SI 87)
                    (reg/v:SI 85 [ num ])))
            (clobber (reg:CC 17 flags))
        ]) "/tmp/t.c":13:14 190 {*addsi_1}

that's a target missed optimization.  I'll fix the MIN/MAX detection
and thus make this issue a target one.

Reply via email to