Skip to content

Commit

Permalink
[X86] Reject xmm16-31 in inline asm constraints when AVX512 is disabled
Browse files Browse the repository at this point in the history
Fixes PR36532

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

llvm-svn: 326596
  • Loading branch information
topperc committed Mar 2, 2018
1 parent 18799f4 commit 6b1419b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Expand Up @@ -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}.
Expand Down
8 changes: 8 additions & 0 deletions llvm/test/CodeGen/X86/asm-reject-xmm16.ll
@@ -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
}

0 comments on commit 6b1419b

Please sign in to comment.