[PATCH] D42697: [GlobalISel] Constrain the dest reg of IMPLICT_DEF
Amara Emerson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 1 17:48:13 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324047: [GlobalISel] Constrain the dest reg of IMPLICT_DEF. (authored by aemerson, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D42697?vs=132035&id=132519#toc
Repository:
rL LLVM
https://reviews.llvm.org/D42697
Files:
llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/select-implicit-def.mir
Index: llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
===================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
+++ llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
@@ -1407,6 +1407,12 @@
: selectVaStartAAPCS(I, MF, MRI);
case TargetOpcode::G_IMPLICIT_DEF:
I.setDesc(TII.get(TargetOpcode::IMPLICIT_DEF));
+ const LLT DstTy = MRI.getType(I.getOperand(0).getReg());
+ const unsigned DstReg = I.getOperand(0).getReg();
+ const RegisterBank &DstRB = *RBI.getRegBank(DstReg, MRI, TRI);
+ const TargetRegisterClass *DstRC =
+ getRegClassForTypeOnBank(DstTy, DstRB, RBI);
+ RBI.constrainGenericRegister(DstReg, *DstRC, MRI);
return true;
}
Index: llvm/trunk/test/CodeGen/AArch64/GlobalISel/select-implicit-def.mir
===================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/select-implicit-def.mir
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/select-implicit-def.mir
@@ -5,6 +5,7 @@
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
define void @implicit_def() { ret void }
+ define void @implicit_def_copy() { ret void }
...
---
@@ -25,3 +26,21 @@
%1(s32) = G_ADD %0, %0
$w0 = COPY %1(s32)
...
+---
+name: implicit_def_copy
+legalized: true
+regBankSelected: true
+registers:
+ - { id: 0, class: gpr }
+ - { id: 1, class: gpr }
+
+body: |
+ bb.0:
+ ; CHECK-LABEL: name: implicit_def_copy
+ ; CHECK: [[DEF:%[0-9]+]]:gpr32 = IMPLICIT_DEF
+ ; CHECK: [[COPY:%[0-9]+]]:gpr32all = COPY [[DEF]]
+ ; CHECK: %w0 = COPY [[COPY]]
+ %0(s32) = G_IMPLICIT_DEF
+ %1(s32) = COPY %0(s32)
+ %w0 = COPY %1(s32)
+...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42697.132519.patch
Type: text/x-patch
Size: 1805 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180202/11e8d306/attachment.bin>
More information about the llvm-commits
mailing list