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

commit r16-8913-gb95c8a32f5387e360d7e867bcc8947094e8531e6
Author: Andi Kleen <[email protected]>
Date:   Wed May 13 16:40:16 2026 -0700

    PR124316: Fix ptwrite assembler mode
    
    Add explicit assembler mode for cases when the argument is not
    unambigious. This avoids cases where a user specified 64bit ptwrite
    ends up being 32bit due to an ambigious argument.
    
            PR target/124316
    
    gcc/ChangeLog:
    
            * config/i386/i386.md (ptwrite): Add explicit mode to
            instruction.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/i386/pr124316.c: New test.

Diff:
---
 gcc/config/i386/i386.md                  |  2 +-
 gcc/testsuite/gcc.target/i386/pr124316.c | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 9c777375c033..e3f690c8c878 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -30189,7 +30189,7 @@
   [(unspec_volatile [(match_operand:SWI48 0 "nonimmediate_operand" "rm")]
                    UNSPECV_PTWRITE)]
   "TARGET_PTWRITE"
-  "ptwrite\t%0"
+  "ptwrite<imodesuffix>\t%0"
   [(set_attr "type" "other")
    (set_attr "prefix_0f" "1")
    (set_attr "prefix_rep" "1")])
diff --git a/gcc/testsuite/gcc.target/i386/pr124316.c 
b/gcc/testsuite/gcc.target/i386/pr124316.c
new file mode 100644
index 000000000000..c1959611a926
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr124316.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-mptwrite" } */
+#include <x86gprintrin.h>
+
+unsigned long long ull;
+unsigned u;
+void foo()
+{
+    _ptwrite64(ull);
+    _ptwrite32(u);
+}
+
+/* { dg-final { scan-assembler-times "ptwritel" 1 } } */
+/* { dg-final { scan-assembler-times "ptwriteq" 1 } } */

Reply via email to