https://gcc.gnu.org/g:cbef1de0b7bbd566ce2250e5a0bada3be9b833c8

commit r17-4247-gcbef1de0b7bbd566ce2250e5a0bada3be9b833c8
Author: Haochen Jiang <[email protected]>
Date:   Wed Sep 9 15:28:44 2026 +0800

    i386: Unify predicate check for ACE tmm reg [PR127264]
    
    gcc/ChangeLog:
    
            PR target/127264
            * config/i386/i386-expand.cc (ix86_expand_ace_builtin):
            Revise logic to avoid INTVAL check for non-constant
            operands.
    
    gcc/testsuite/ChangeLog:
    
            PR target/127264
            * gcc.target/i386/pr127264.c: New test.

Diff:
---
 gcc/config/i386/i386-expand.cc           | 17 +++++++----------
 gcc/testsuite/gcc.target/i386/pr127264.c |  7 +++++++
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index 1c049d0c4410..04fef5841580 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -14773,19 +14773,16 @@ ix86_expand_ace_builtin (const struct 
builtin_description *d, tree exp,
 
       if (i == 0 || i == constant)
        {
-         if (i == 0 && !IN_RANGE (INTVAL (op), 0, 7))
+         if (!insn_p->operand[i + arg_adjust].predicate (op, SImode))
            {
-             /* This must be the tmm reg number constant.  */
-             error ("the tmm register number argument must be between 0 to 7");
-             return const0_rtx;
-           }
-         else if (!insn_p->operand[i + arg_adjust].predicate(op, SImode))
-           {
-             /* This must be the constant.  */
-             error ("the argument must be constant");
+             if (i == 0)
+               /* This must be the tmm reg number constant.  */
+               error ("the tmm register number argument must be between 0 to 
7");
+             else
+               /* This must be the constant.  */
+               error ("the argument must be constant");
              return const0_rtx;
            }
-
        }
       else
        {
diff --git a/gcc/testsuite/gcc.target/i386/pr127264.c 
b/gcc/testsuite/gcc.target/i386/pr127264.c
new file mode 100644
index 000000000000..c83362f4b056
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr127264.c
@@ -0,0 +1,7 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O2 -macev1" } */
+
+void ace (char c)
+{
+  __builtin_ia32_tilezero (c); /* { dg-error "the tmm register number argument 
must be between 0 to 7" "" { target { ! ia32 } } 0 } */
+}

Reply via email to