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

--- Comment #2 from Daniel Petrovic <daniel-dev at hotmail dot de> ---
Don't have solution yet, but just trying to summarize patterns from
match-sat-alu.pd which may be affected by the new fold:

P1: 
 (match (signed_integer_sat_add @0 @1)
  /* T SUM = (T)((UT)X + (UT)Y)
     SAT_S_ADD = (X ^ Y) < 0 && (X ^ SUM) >= 0 ? (-(T)(X < 0) ^ MAX) : SUM  */
  (cond^ (bit_and:c (lt (bit_xor @0 (nop_convert@2 (plus (nop_convert @0)
                                                         (nop_convert @1))))
                        integer_zerop)
                    (ge (bit_xor:c @0 @1) integer_zerop))
         (signed_integer_sat_val @0)
         @2))


P2:
(match (signed_integer_sat_add @0 @1)
  /* T SUM = (T)((UT)X + (UT)IMM)
     SAT_S_ADD = (X ^ SUM) < 0 && (X ^ IMM) >= 0 ? (-(T)(X < 0) ^ MAX) : SUM 
*/
  (cond^ (bit_and:c (lt (bit_xor @0 (nop_convert@2 (plus (nop_convert @0)
                                                         INTEGER_CST@1)))
                        integer_zerop)
                    (ge (bit_xor:c @0 INTEGER_CST@3) integer_zerop))
         (signed_integer_sat_val @0)
         @2)

P3:
(match (signed_integer_sat_add @0 @1)
  /* T SUM = (T)((UT)X + (UT)Y)
     SAT_S_ADD = (X ^ SUM) < 0 & ~((X ^ Y) < 0) ? (-(T)(X < 0) ^ MAX) : SUM  */
  (cond^ (bit_and:c (lt (bit_xor @0 (nop_convert@2 (plus (nop_convert @0)
                                                         (nop_convert @1))))
                        integer_zerop)
                    (bit_not (lt (bit_xor:c @0 @1) integer_zerop)))
         (signed_integer_sat_val @0)
         @2))

  (if (wi::eq_p (wi::to_wide (@1), wi::to_wide (@3)))))

P4:
(match (signed_integer_sat_sub @0 @1)
  /* T Z = (T)((UT)X - (UT)Y);
     SAT_S_SUB = (X ^ Y) < 0 & (X ^ Z) < 0 ? (-(T)(X < 0) ^ MAX) : Z  */
  (cond^ (bit_and:c (lt (bit_xor @0 (nop_convert@2 (minus (nop_convert @0)
                                                          (nop_convert @1))))
                        integer_zerop)
                    (lt (bit_xor:c @0 @1) integer_zerop))
         (signed_integer_sat_val @0)
         @2))

Reply via email to