[PATCH] D61457: [X86] Use extended vector register classes in getRegForInlineAsmConstraint to support x/y/zmm16-31 when the type is mismatched.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 2 12:25:54 PDT 2019


craig.topper created this revision.
craig.topper added reviewers: rnk, RKSimon, spatel.
Herald added a project: LLVM.

The FR32/FR64/VR128/VR256 register classes don't contain the upper 16 registers. For most cases we use the default implementation which will find any register class that contains the register in question if the VT is legal for the register class. But if the VT is i32 or i64, we won't find a matching register class and will instead up in the code modified in this patch.

If the requested register is x/y/zmm16-31 we weren't returning a register class that contains those registers and will hit an assertion in the caller.

To fix this, I've changed to use the extended register class instead. I don't believe we need a subtarget check to see if avx512 is enabled. The default implementation just pick whatever register class it finds first. I checked and we currently pick FR32X for XMM0 with an f32 type using the default implementation regardless of whether avx512 is enabled. So I assume its it is ok to do the same for i32.


https://reviews.llvm.org/D61457

Files:
  llvm/test/CodeGen/X86/asm-reg-type-mismatch-avx512.ll


Index: llvm/test/CodeGen/X86/asm-reg-type-mismatch-avx512.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/asm-reg-type-mismatch-avx512.ll
@@ -0,0 +1,15 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=avx512f | FileCheck %s
+
+define i64 @test1() nounwind {
+; CHECK-LABEL: test1:
+; CHECK:       # %bb.0: # %entry
+; CHECK-NEXT:    #APP
+; CHECK-NEXT:    vmovq {{.*#+}} xmm16 = mem[0],zero
+; CHECK-NEXT:    #NO_APP
+; CHECK-NEXT:    vmovq %xmm16, %rax
+; CHECK-NEXT:    retq
+entry:
+  %0 = tail call i64 asm sideeffect "vmovq $1, $0", "={xmm16},*m,~{dirflag},~{fpsr},~{flags}"(i64* null) nounwind
+  ret i64 %0
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61457.197842.patch
Type: text/x-patch
Size: 771 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190502/f45f1696/attachment.bin>


More information about the llvm-commits mailing list