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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
            Version|tree-ssa                    |10.0
   Last reconfirmed|                            |2020-04-14
             Status|UNCONFIRMED                 |NEW
             Target|                            |x86_64-*-* i?86-*-*
           Keywords|                            |missed-optimization
          Component|middle-end                  |rtl-optimization

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that we fail to have a proper representation of the target on the
GIMPLE level.  We expand to RTL from the optimal

  <bb 2> [local count: 1073741824]:
  # RANGE [0, 255] NONZERO 255
  _1 = MIN_EXPR <x_2(D), 255>;
  # RANGE [0, 255] NONZERO 255
  _3 = (unsigned int) _1;
  return _3;

but that produces

(insn 10 6 9 (set (reg:HI 88)
        (const_int 255 [0xff])) "x.c":1:56 -1
     (nil))

(insn 9 10 11 (set (reg:CC 17 flags)
        (compare:CC (reg/v:HI 84 [ x ])
            (const_int 255 [0xff]))) "x.c":1:56 -1
     (nil))

(insn 11 9 12 (set (reg:HI 87)
        (if_then_else:HI (leu (reg:CC 17 flags)
                (const_int 0 [0]))
            (reg/v:HI 84 [ x ])
            (reg:HI 88))) "x.c":1:56 -1
     (nil))

(insn 12 11 13 (set (reg:SI 86)
        (zero_extend:SI (reg:HI 87))) "x.c":1:61 -1
     (nil))

given fort the (unsigned int) _1 zero-extension we don't have any other
representation on GIMPLE to elide the zero-extension.  I'm also not
sure if (subreg:SI (reg:HI 87)) would be correct in all cases.

Marking rtl-optimization but eventually it's also a target issue.

We also don't have anything like a reg-note to tell ranges of a
set?  Anyway, even on RTL the range of reg:HI 87 is clearly visible.

Reply via email to