@@ -541,6 +541,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(bit_ior:c (bit_and @0 INTEGER_CST@2) (bit_and (bit_not @0) INTEGER_CST@1))
(if (wi::bit_not (@2) == @1)
(bit_xor @0 @1)))
+
+/* PR53979: Transform ((a ^ b) | a) -> (a | b) */
+(simplify
+ (bit_ior:c (bit_xor:c @0 @1) @0)
+ (bit_ior @0 @1))
+
/* Simplify (~X & Y) to X ^ Y if we know that (X & ~Y) is 0. */
#if GIMPLE
(simplify
new file mode 100644
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-gimple" } */
+
+unsigned f1(unsigned a, unsigned b)
+{
+ return (a ^ b) | a;
+}
+
+/* { dg-final { scan-tree-dump "a | b" "gimple" } } */
new file mode 100644
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-forwprop-details" } */
+
+unsigned f(unsigned a, unsigned b)
+{
+ unsigned t1 = a ^ b;
+ unsigned t2 = t1 | a;
+ return t2;
+}
+
+/* { dg-final { scan-tree-dump "gimple_simplified to t2_\[0-9\] = a_\[0-9\]*\\(D\\) | b_\[0-9\]*\\(D\\)" "forwprop1" } } */