[X86] Reject xmm16-31 in inline asm constraints when AVX512 is disabled
authorCraig Topper <craig.topper@intel.com>
Fri, 2 Mar 2018 18:19:40 +0000 (18:19 +0000)
committerCraig Topper <craig.topper@intel.com>
Fri, 2 Mar 2018 18:19:40 +0000 (18:19 +0000)
Fixes PR36532

Differential Revision: https://reviews.llvm.org/D43960

llvm-svn: 326596

llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/asm-reject-xmm16.ll [new file with mode: 0644]

index 56c6bd9..1511511 100644 (file)
@@ -39160,6 +39160,15 @@ X86TargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
     return Res;
   }
 
+  // Make sure it isn't a register that requires AVX512.
+  if (!Subtarget.hasAVX512() && isFRClass(*Res.second) &&
+      TRI->getEncodingValue(Res.first) & 0x10) {
+    // Register requires EVEX prefix.
+    Res.first = 0;
+    Res.second = nullptr;
+    return Res;
+  }
+
   // Otherwise, check to see if this is a register class of the wrong value
   // type.  For example, we want to map "{ax},i32" -> {eax}, we don't want it to
   // turn into {ax},{dx}.
diff --git a/llvm/test/CodeGen/X86/asm-reject-xmm16.ll b/llvm/test/CodeGen/X86/asm-reject-xmm16.ll
new file mode 100644 (file)
index 0000000..eee0064
--- /dev/null
@@ -0,0 +1,8 @@
+; RUN: not llc -o /dev/null %s 2>&1 | FileCheck %s
+target triple = "x86_64--"
+
+; CHECK: error: couldn't allocate output register for constraint '{xmm16}'
+define i64 @blup() {
+  %v = tail call i64 asm "", "={xmm16},0"(i64 0)
+  ret i64 %v
+}