]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[APX] i386: Use setzucc by default when APX-ZU enabled
authorHongyu Wang <hongyu.wang@intel.com>
Wed, 21 May 2025 01:45:03 +0000 (09:45 +0800)
committerHongyu Wang <hongyu.wang@intel.com>
Mon, 29 Dec 2025 01:15:58 +0000 (09:15 +0800)
When APX-ZU enabled, all legacy setcc can directly use zu sematic to
avoid potential partial-dependency.

gcc/ChangeLog:

* config/i386/i386.md (*setcc_qi): Force output setzucc for
reg operand[0].
(*setcc_qi_slp): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/i386/apx-zu-3.c: New test.

gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/apx-zu-3.c [new file with mode: 0644]

index cae1e1016e0535527da67a79a50b96885ac79fe7..ccc927ca5ec0a3087aa9767e0280008cea74f8f4 100644 (file)
        (match_operator:QI 1 "ix86_comparison_operator"
          [(reg FLAGS_REG) (const_int 0)]))]
   ""
-  "set%C1\t%0"
+{
+  if (REG_P (operands[0])
+      && TARGET_APX_ZU)
+    return "setzu%C1\t%0";
+  else
+    return "set%C1\t%0";
+}
   [(set_attr "type" "setcc")
    (set_attr "mode" "QI")])
 
        (match_operator:QI 1 "ix86_comparison_operator"
          [(reg FLAGS_REG) (const_int 0)]))]
   ""
-  "set%C1\t%0"
+{
+  if (TARGET_APX_ZU)
+    return "setzu%C1\t%0";
+  else
+    return "set%C1\t%0";
+}
   [(set_attr "type" "setcc")
    (set_attr "mode" "QI")])
 
diff --git a/gcc/testsuite/gcc.target/i386/apx-zu-3.c b/gcc/testsuite/gcc.target/i386/apx-zu-3.c
new file mode 100644 (file)
index 0000000..3028c93
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-mapxf -march=x86-64 -O2" } */
+/* { dg-final { scan-assembler-times "setzune" 1} } */
+
+char foo0 (int a)
+{
+  return a == 0 ? 0 : 1;
+}