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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org
          Component|tree-optimization           |middle-end
             Status|NEW                         |ASSIGNED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
  _1 = t_3(D) & 256;
  if (_1 != 0)
    goto <bb 4>; [1.04%]
  else
    goto <bb 3>; [98.96%]

  <bb 3> [local count: 1062574912]:

  <bb 4> [local count: 1073741824]:
  # _2 = PHI <-26(2), 0(3)>


So the trick here is that 256 is `0x1<<8` so we want to shift that bit up to
the sign bit and then arthimetic shift down to get 0/-1 and then and with -26.

It seems like we could do this in ifcvt I think.

we do find the block:

IF-THEN-JOIN block found, pass 1, test 2, then 3, join 4

IF-CASE-2 found, start 2, else 3


but we don't optimize it (on aarch64 we use csel).

We could do this on the gimple level with a match pattern.

(simplify
 (cond (ne (and @0 integer_pow2p@1) integer_zerop) INTEGER_CST@2 integer_zerop)
....

Maybe only do this late and if shift is cheap (though there is no predicates
for that yet).

Reply via email to