On 11/22/26 3:00 PM, Daniel Petrovic wrote:
Best guess is the optimized form causes us to miss the saturation discovery ..
Yes, seems to be the case. In match-sat-alu.pd   there are matchers like this 
one, for example:

  (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)
...

Some of these matchers seem don't to trigger any more after our new fold.

I guess we need either some new sat-matchers to consider  our new fold, or  we 
have to exclude some cases from the new folds so that old sat-matchers trigger.
Or maybe something else ?

The former variant seems more correct to me.
Agreed.  But the latter is an option, especially if we lose too much information in the transformation to safely re-discover the saturating arithmetic.


I'll have more time to look into this towards middle of the week.
Works for me.


As an aside, it would be useful to move/copy some of these SAT_ADD
detection testcases to be in the vect.exp testsuite with the
appropriate target supports and scanning for SAT_ADD.
Makes sense. I can check that too.
Thanks.  I outlined the two biggest concerns I can think of, but would totally agree it's useful to get them moved.
jeff

Reply via email to