[llvm] r292461 - GlobalISel: Implement narrowing for G_LOAD
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 18 17:05:48 PST 2017
Author: bogner
Date: Wed Jan 18 19:05:48 2017
New Revision: 292461
URL: http://llvm.org/viewvc/llvm-project?rev=292461&view=rev
Log:
GlobalISel: Implement narrowing for G_LOAD
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-load-store.mir
Modified: llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp?rev=292461&r1=292460&r2=292461&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp Wed Jan 18 19:05:48 2017
@@ -161,6 +161,32 @@ LegalizerHelper::LegalizeResult Legalize
MI.eraseFromParent();
return Legalized;
}
+ case TargetOpcode::G_LOAD: {
+ unsigned NarrowSize = NarrowTy.getSizeInBits();
+ int NumParts =
+ MRI.getType(MI.getOperand(0).getReg()).getSizeInBits() / NarrowSize;
+ LLT NarrowPtrTy = LLT::pointer(
+ MRI.getType(MI.getOperand(1).getReg()).getAddressSpace(), NarrowSize);
+
+ SmallVector<unsigned, 2> DstRegs;
+ SmallVector<uint64_t, 2> Indexes;
+ for (int i = 0; i < NumParts; ++i) {
+ unsigned DstReg = MRI.createGenericVirtualRegister(NarrowTy);
+ unsigned SrcReg = MRI.createGenericVirtualRegister(NarrowPtrTy);
+ unsigned Offset = MRI.createGenericVirtualRegister(LLT::scalar(64));
+
+ MIRBuilder.buildConstant(Offset, i * NarrowSize / 8);
+ MIRBuilder.buildGEP(SrcReg, MI.getOperand(1).getReg(), Offset);
+ MIRBuilder.buildLoad(DstReg, SrcReg, **MI.memoperands_begin());
+
+ DstRegs.push_back(DstReg);
+ Indexes.push_back(i * NarrowSize);
+ }
+ unsigned DstReg = MI.getOperand(0).getReg();
+ MIRBuilder.buildSequence(DstReg, DstRegs, Indexes);
+ MI.eraseFromParent();
+ return Legalized;
+ }
case TargetOpcode::G_STORE: {
unsigned NarrowSize = NarrowTy.getSizeInBits();
int NumParts =
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-load-store.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-load-store.mir?rev=292461&r1=292460&r2=292461&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-load-store.mir (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-load-store.mir Wed Jan 18 19:05:48 2017
@@ -24,6 +24,7 @@ registers:
- { id: 5, class: _ }
- { id: 6, class: _ }
- { id: 7, class: _ }
+ - { id: 8, class: _ }
body: |
bb.0.entry:
liveins: %x0, %x1, %x2, %x3
@@ -51,6 +52,15 @@ body: |
; CHECK: %7(<2 x s32>) = G_LOAD %0(p0) :: (load 8 from %ir.addr)
%7(<2 x s32>) = G_LOAD %0(p0) :: (load 8 from %ir.addr)
+
+ ; CHECK: [[OFFSET0:%[0-9]+]](s64) = G_CONSTANT i64 0
+ ; CHECK: [[GEP0:%[0-9]+]](p0) = G_GEP %0, [[OFFSET0]](s64)
+ ; CHECK: [[LOAD0:%[0-9]+]](s64) = G_LOAD [[GEP0]](p0) :: (load 16 from %ir.addr)
+ ; CHECK: [[OFFSET1:%[0-9]+]](s64) = G_CONSTANT i64 8
+ ; CHECK: [[GEP1:%[0-9]+]](p0) = G_GEP %0, [[OFFSET1]](s64)
+ ; CHECK: [[LOAD1:%[0-9]+]](s64) = G_LOAD [[GEP1]](p0) :: (load 16 from %ir.addr)
+ ; CHECK: %8(s128) = G_SEQUENCE [[LOAD0]](s64), 0, [[LOAD1]](s64), 64
+ %8(s128) = G_LOAD %0(p0) :: (load 16 from %ir.addr)
...
---
More information about the llvm-commits
mailing list