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

--- Comment #6 from Jeffrey A. Law <law at gcc dot gnu.org> ---
ISTM this should likely be tackled in both the gimple and RTL levels.  In
gimple it would be a suitable match.pd pattern.  For RTL it would be
simplify-rtx.

Gimple looks pretty straighforward.  If we take the first example we have:

  _1 = ~x_4(D);
  _2 = _1 >> 3;
  _3 = _2 != 0;
  _5 = (int) _3;

Working backwards from that we can build a suitable matcher (and obviously it
needs to be generalized).  For the simplified form we'd target something like:


  x.0_1 = (unsigned int) x_3(D);
  _2 = x.0_1 <= 4294967287;
  _4 = (int) _2;


On the RTL side we're going to see something like this in simplify-rtx:

(set (reg:SI 143 [ _3 ])
    (ne:SI (lshiftrt:SI (reg:SI 144 [ x ])
            (const_int 3 [0x3]))
        (const_int 536870911 [0x1fffffff])))

And I think we target something like this for the simplified RTL:

(set (reg:SI 143)
     (leu:SI (reg 144) (const_int -9))

Reply via email to