[llvm] 3e89cc5 - [X86] Remove isel predicates for xgetbv/xsetbv instructions so they can work on Windows.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 2 10:25:23 PDT 2021
Author: Craig Topper
Date: 2021-09-02T10:25:02-07:00
New Revision: 3e89cc5cda22bdc35b1d0a21e6d8eae08a4f61dc
URL: https://github.com/llvm/llvm-project/commit/3e89cc5cda22bdc35b1d0a21e6d8eae08a4f61dc
DIFF: https://github.com/llvm/llvm-project/commit/3e89cc5cda22bdc35b1d0a21e6d8eae08a4f61dc.diff
LOG: [X86] Remove isel predicates for xgetbv/xsetbv instructions so they can work on Windows.
https://reviews.llvm.org/D56686 was supposed to allow these to
work on Windows without needing to enable the xsave feature to
match MSVC. It seems this didn't work because the backend isel
patterns would still block it.
This patch removes the predicates from the isel patterns.
Fixes PR51706.
Reviewed By: pengfei
Differential Revision: https://reviews.llvm.org/D109097
Added:
Modified:
llvm/lib/Target/X86/X86InstrSystem.td
llvm/test/CodeGen/X86/system-intrinsics-xsetbv.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86InstrSystem.td b/llvm/lib/Target/X86/X86InstrSystem.td
index 48c27051a872..0f86f0364ccd 100644
--- a/llvm/lib/Target/X86/X86InstrSystem.td
+++ b/llvm/lib/Target/X86/X86InstrSystem.td
@@ -529,16 +529,17 @@ let SchedRW = [WriteSystem] in {
//===----------------------------------------------------------------------===//
// XSAVE instructions
let SchedRW = [WriteSystem] in {
-let Predicates = [HasXSAVE] in {
+// NOTE: No HasXSAVE predicate so that these can be used with _xgetbv/_xsetbv
+// on Windows without needing to enable the xsave feature to be compatible with
+// MSVC.
let Defs = [EDX, EAX], Uses = [ECX] in
- def XGETBV : I<0x01, MRM_D0, (outs), (ins), "xgetbv", []>, PS;
+def XGETBV : I<0x01, MRM_D0, (outs), (ins), "xgetbv", []>, PS;
let Uses = [EDX, EAX, ECX] in
- def XSETBV : I<0x01, MRM_D1, (outs), (ins),
- "xsetbv",
- [(int_x86_xsetbv ECX, EDX, EAX)]>, PS;
+def XSETBV : I<0x01, MRM_D1, (outs), (ins),
+ "xsetbv",
+ [(int_x86_xsetbv ECX, EDX, EAX)]>, PS;
-} // HasXSAVE
let Uses = [EDX, EAX] in {
def XSAVE : I<0xAE, MRM4m, (outs), (ins opaquemem:$dst),
diff --git a/llvm/test/CodeGen/X86/system-intrinsics-xsetbv.ll b/llvm/test/CodeGen/X86/system-intrinsics-xsetbv.ll
index a0961a097ec2..64ae257cb376 100644
--- a/llvm/test/CodeGen/X86/system-intrinsics-xsetbv.ll
+++ b/llvm/test/CodeGen/X86/system-intrinsics-xsetbv.ll
@@ -1,5 +1,5 @@
-; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+xsave | FileCheck %s
-; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+xsave | FileCheck %s --check-prefix=CHECK64
+; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=CHECK64
define void @test_xsetbv(i32 %in, i32 %high, i32 %low) {
; CHECK-LABEL: test_xsetbv
More information about the llvm-commits
mailing list