@@ -3274,8 +3274,22 @@ (define_insn_and_split "*andsi_iorsi3_notsi"
"#" ; "orr%?\\t%0, %1, %2\;bic%?\\t%0, %0, %3"
"&& reload_completed"
[(set (match_dup 0) (ior:SI (match_dup 1) (match_dup 2)))
- (set (match_dup 0) (and:SI (not:SI (match_dup 3)) (match_dup 0)))]
- ""
+ (set (match_dup 0) (and:SI (match_dup 4) (match_dup 5)))]
+ {
+ /* If operands[3] is a constant make sure to fold the NOT into it
+ to avoid creating a NOT of a CONST_INT. */
+ rtx not_rtx = simplify_gen_unary (NOT, SImode, operands[3], SImode);
+ if (CONST_INT_P (not_rtx))
+ {
+ operands[4] = operands[0];
+ operands[5] = not_rtx;
+ }
+ else
+ {
+ operands[5] = operands[0];
+ operands[4] = not_rtx;
+ }
+ }
[(set_attr "length" "8")
(set_attr "ce_count" "2")
(set_attr "predicable" "yes")
new file mode 100644
@@ -0,0 +1,20 @@
+int __attribute__ ((noinline))
+foo (void)
+{
+ return 123;
+}
+
+int __attribute__ ((noinline))
+bar (void)
+{
+ int c = 1;
+ c |= 4294967295 ^ (foo () | 4073709551608);
+ return c;
+}
+
+int
+main ()
+{
+ if (bar () != 0x83fd4005)
+ __builtin_abort ();
+}