]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR124316: Fix ptwrite assembler mode
authorAndi Kleen <ak@gcc.gnu.org>
Wed, 13 May 2026 23:40:16 +0000 (16:40 -0700)
committerAndi Kleen <ak@gcc.gnu.org>
Thu, 14 May 2026 17:12:57 +0000 (10:12 -0700)
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.

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

index a486ea3d79d50f165655f979fa05aa056851e69b..fa84da26aa89a57812e171b496100aa3d9bb0884 100644 (file)
   [(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 (file)
index 0000000..c195961
--- /dev/null
@@ -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 } } */