On Mon, 12 Oct 2015, Hurugalawadi, Naveen wrote:
+/* Fold X + (X / CST) * -CST to X % CST. */
+(simplify
+ (plus (convert1? @0) (convert2? (mult (trunc_div @0 INTEGER_CST@1)
INTEGER_CST@2)))
+ (if ((INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (type))
+ && wi::add (@1, @2) == 0)
+ (trunc_mod (convert @0) (convert @1))))
With INTEGER_CST above, the test INTEGRAL_TYPE_P might be redundant, and
VECTOR_INTEGER_TYPE_P can never match.
+/* Fold (A & ~B) - (A & B) into (A ^ B) - B. */
+(simplify
+ (minus (bit_and:s @0 (bit_not @1)) (bit_and:s @0 @2))
+ (if (! FLOAT_TYPE_P (type)
+ && wi::eq_p (@1, @2))
+ (minus (bit_xor @0 @1) @1)))
I don't think FLOAT_TYPE_P can ever be true for the result of bit_and.
+/* Fold (a * (1 << b)) into (a << b) */
+(simplify
+ (mult:c (convert1? @0) (convert2? (lshift integer_onep@1 @2)))
+ (if (! FLOAT_TYPE_P (type))
+ (lshift (convert @0) (convert @2))))
If a and 1 are vectors and b is a scalar...
+/* Simplify (X & ~Y) | (~X & Y) is X ^ Y. */
+(simplify
+ (bit_ior (bit_and:s @0 (bit_not @1)) (bit_and:s (bit_not @2) @3))
+ (if (wi::eq_p (@0, @2)
+ && wi::eq_p (@1, @3))
+ (bit_xor @0 @3)))
I don't think we need the :s when the result of the transformation is so
simple.
+/* Simplify ~X & X as zero. */
+(simplify
+ (bit_and:c (convert? @0) (convert? (bit_not @0)))
+ (convert { build_zero_cst (TREE_TYPE (@0)); }))
Can't you build 0 directly in the right type?
--
Marc Glisse