Fix ICE of unrecognizable insn. [PR target/104001]
authorliuhongt <hongtao.liu@intel.com>
Thu, 13 Jan 2022 14:51:49 +0000 (22:51 +0800)
committerliuhongt <hongtao.liu@intel.com>
Fri, 14 Jan 2022 05:02:26 +0000 (13:02 +0800)
For define_insn_and_split "*xor2andn":

1. Refine predicate of operands[0] from nonimmediate_operand to
register_operand.
2. Remove TARGET_AVX512BW from condition to avoid kmov when TARGET_BMI
is not available.

gcc/ChangeLog:

PR target/104001
PR target/94790
PR target/104014
* config/i386/i386.md (*xor2andn): Refine predicate of
operands[0] from nonimmediate_operand to
register_operand, remove TARGET_AVX512BW from condition.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr104001.c: New test.

gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/pr104001.c [new file with mode: 0644]

index c2acb1d..9477ca9 100644 (file)
    (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
diff --git a/gcc/testsuite/gcc.target/i386/pr104001.c b/gcc/testsuite/gcc.target/i386/pr104001.c
new file mode 100644 (file)
index 0000000..4efb593
--- /dev/null
@@ -0,0 +1,21 @@
+/* { 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));
+}