[PATCH] D157458: [X86][AMX] Fix virtual register traversing in case of GlobalIsel
Evgenii Kudriashov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 8 17:13:06 PDT 2023
e-kud updated this revision to Diff 548410.
e-kud added a comment.
Typo
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157458/new/
https://reviews.llvm.org/D157458
Files:
llvm/include/llvm/CodeGen/MachineRegisterInfo.h
llvm/lib/Target/X86/X86FastPreTileConfig.cpp
llvm/test/CodeGen/X86/AMX/amx-fastpreconfig-gisel.ll
Index: llvm/test/CodeGen/X86/AMX/amx-fastpreconfig-gisel.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/AMX/amx-fastpreconfig-gisel.ll
@@ -0,0 +1,14 @@
+; RUN: llc -mtriple=x86_64-- -stop-after fastpretileconfig -global-isel -O0 -o - %s | FileCheck %s
+
+; GlobalIsel doesn't use all virtual registers and there may be holes
+; during consecutive iteration of them. Note that %3 is absent.
+; https://github.com/llvm/llvm-project/issues/64452
+define i64 @f(i64 %0, i64 %1) {
+entry:
+; CHECK: liveins
+; CHECK-NOT: %3:
+; CHECK: RET 0, implicit $rax
+ %2 = lshr i64 %0, %1
+ %3 = add i64 %2, 123456789
+ ret i64 %3
+}
Index: llvm/lib/Target/X86/X86FastPreTileConfig.cpp
===================================================================
--- llvm/lib/Target/X86/X86FastPreTileConfig.cpp
+++ llvm/lib/Target/X86/X86FastPreTileConfig.cpp
@@ -668,7 +668,8 @@
bool HasVirtTileReg = false;
for (unsigned I = 0, E = NumVirtRegs; I != E; ++I) {
Register VirtReg = Register::index2VirtReg(I);
- if (MRI->getRegClass(VirtReg)->getID() == X86::TILERegClassID) {
+ const TargetRegisterClass *RC = MRI->getRegClassOrNull(VirtReg);
+ if (RC && RC->getID() == X86::TILERegClassID) {
HasVirtTileReg = true;
break;
}
Index: llvm/include/llvm/CodeGen/MachineRegisterInfo.h
===================================================================
--- llvm/include/llvm/CodeGen/MachineRegisterInfo.h
+++ llvm/include/llvm/CodeGen/MachineRegisterInfo.h
@@ -672,9 +672,9 @@
/// conditions are met:
/// 1. Generic virtual registers are created.
/// 2. The machine function has not completely been through the
- /// instruction selection process.
+ /// instruction selection process or selected using GlobalISel.
/// None of this condition is possible without GlobalISel for now.
- /// In other words, if GlobalISel is not used or if the query happens after
+ /// In other words, if GlobalISel is not used and if the query happens after
/// the select pass, using getRegClass is safe.
const TargetRegisterClass *getRegClassOrNull(Register Reg) const {
const RegClassOrRegBank &Val = VRegInfo[Reg].first;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157458.548410.patch
Type: text/x-patch
Size: 2224 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230809/5ac373af/attachment.bin>
More information about the llvm-commits
mailing list