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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot 
gnu.org

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
For the scalar we have:

  _1 = a_5(D) > b_6(D);
  _9 = _2 + -1;
  _4 = b_6(D) & _9;

Where _2 is zero_one_valued_p.

So we could match that:
/* ((m1 CMP m2) + -1) & d -> (m1 CMP m2) ? 0 : d  */
  (simplify
   (bit_and:c (plus (convert (cmp@0 @1 @2)) integer_minus_onep) @3)
   (if (INTEGRAL_TYPE_P (type)
        && INTEGRAL_TYPE_P (TREE_TYPE (@0)))
     (cond @0 { build_zero_cst (type); } @3)))

Like we do already for `(-(m1 CMP m2)) & d -> (m1 CMP m2) ? d : 0`.

This should get us:
  _3 = _1 ? a_5(D) : 0;
  _4 = _1 ? 0 : b_6(D);
  _7 = _3 | _4;

Which then can be reduced to:
_7 = _1 ? a_5(D) : b_6(D)

via (maybe a new pattern):
(simplify
 (bit_ior:c
  (cond @0 @1 integer_zerop)
  (cond @0 integer_zerop @2))
 (cond @0 @1 @2))

Which then will match.
Let me see if I can implement the above.

Reply via email to