(set_attr "znver1_decode" "double")
(set_attr "mode" "DI")])
-;; PR target/94790: Optimize a ^ ((a ^ b) & mask) to (~mask & a) | (b & mask)
+;; Optimize a ^ ((a ^ b) & mask) to (~mask & a) | (b & mask)
(define_insn_and_split "*xor2andn"
- [(set (match_operand:SWI248 0 "nonimmediate_operand")
+ [(set (match_operand:SWI248 0 "register_operand")
(xor:SWI248
(and:SWI248
(xor:SWI248
(match_operand:SWI248 3 "nonimmediate_operand"))
(match_dup 1)))
(clobber (reg:CC FLAGS_REG))]
- "(TARGET_BMI || TARGET_AVX512BW)
- && ix86_pre_reload_split ()"
+ "TARGET_BMI && ix86_pre_reload_split ()"
"#"
"&& 1"
[(parallel [(set (match_dup 4)
(clobber (reg:CC FLAGS_REG))])
(parallel [(set (match_dup 5)
(and:SWI248
- (match_dup 2)
- (match_dup 3)))
+ (match_dup 3)
+ (match_dup 2)))
(clobber (reg:CC FLAGS_REG))])
(parallel [(set (match_dup 0)
(ior:SWI248
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not "kandn" } } */
+/* { dg-final { scan-assembler "andn" } } */
+
+int b, c, d;
+int r;
+
+void
+__attribute__((target("bmi")))
+foo ()
+{
+ r = ((b & ~d) | (c & d));
+}
+
+void
+__attribute__((target("avx512bw")))
+bar ()
+{
+ r = ((b & ~d) | (c & d));
+}