/* (a | b) & (a == b) --> a & b (boolean version of the above). */
(simplify
(bit_and:c (bit_ior @0 @1) (nop_convert? (eq:c @0 @1)))
- (bit_and @0 @1))
+ (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
+ && TYPE_PRECISION (TREE_TYPE (@0)) == 1)
+ (bit_and @0 @1)))
/* a | ~(a ^ b) --> a | ~b */
(simplify
/* a | (a == b) --> a | (b^1) (boolean version of the above). */
(simplify
(bit_ior:c @0 (nop_convert? (eq:c @0 @1)))
- (bit_ior @0 (bit_xor @1 { build_one_cst (type); })))
+ (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
+ && TYPE_PRECISION (TREE_TYPE (@0)) == 1)
+ (bit_ior @0 (bit_xor @1 { build_one_cst (type); }))))
/* (a | b) | (a &^ b) --> a | b */
(for op (bit_and bit_xor)
/* (a & b) | (a == b) --> a == b */
(simplify
(bit_ior:c (bit_and:c @0 @1) (nop_convert?@2 (eq @0 @1)))
- @2)
+ (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))
+ && TYPE_PRECISION (TREE_TYPE (@0)) == 1)
+ @2))
/* ~(~a & b) --> a | ~b */
(simplify
--- /dev/null
+/* PR tree-optimization/110726 */
+
+#define DECLS(n,VOL) \
+__attribute__((noinline,noclone)) \
+int h##n(VOL int A, VOL int B){ \
+ return (A | B) & (A == B); \
+} \
+__attribute__((noinline,noclone)) \
+int i##n(VOL int A, VOL int B){ \
+ return A | (A == B); \
+} \
+__attribute__((noinline,noclone)) \
+int k##n(VOL int A, VOL int B){ \
+ return (A & B) | (A == B); \
+} \
+
+DECLS(0,)
+DECLS(1,volatile)
+
+int values[] = { 0, 1, 2, 3, -1, -2, -3, 0x10080 };
+int numvalues = sizeof(values)/sizeof(values[0]);
+
+int main(){
+ for(int A = 0; A < numvalues; A++)
+ for(int B = 0; B < numvalues; B++)
+ {
+ int a = values[A];
+ int b = values[B];
+ if (h0 (a, b) != h1 (a, b)) __builtin_abort();
+ if (i0 (a, b) != i1 (a, b)) __builtin_abort();
+ if (k0 (a, b) != k1 (a, b)) __builtin_abort();
+ }
+}