On Thu, 7 Apr 2016, Hurugalawadi, Naveen wrote:
+/* Fold A * 10 == B * 10 into A == B. */ +(for cmp (eq ne) + (simplify + (cmp (mult:c @0 @1) (mult:c @2 @1)) + (if (TYPE_OVERFLOW_UNDEFINED (type)
type is the return type of the comparison. The relevant type here is TREE_TYPE (@0). Maybe add a testcase with unsigned, to check that it does not transform?
+ && !integer_zerop (@1)) + (cmp @0 @2))))
!integer_zerop is not a promise that the variable is not zero, it just says that we don't know for sure that it is zero. integer_nonzerop would work. Or writing (cmp (mult @0 INTEGER_CST@1) (mult @2 @1)), but then !wi::eq_p (@1, 0) would be a better test. To make it more general (not limited to constants), you could probably use tree_expr_nonzero_p, and at some point someone would enhance tree_single_nonzero_warnv_p by checking VRP information for SSA_NAME. The other transformation has similar issues. -- Marc Glisse