[llvm] r366656 - [GISel]: Attach missing range metadata while translating G_LOADs
Aditya Nandakumar via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 21 07:07:54 PDT 2019
Author: aditya_nandakumar
Date: Sun Jul 21 07:07:54 2019
New Revision: 366656
URL: http://llvm.org/viewvc/llvm-project?rev=366656&view=rev
Log:
[GISel]: Attach missing range metadata while translating G_LOADs
https://reviews.llvm.org/D65048
Attach range information to G_LOAD when only defining one register.
reviewed by: arsenm
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
Modified: llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp?rev=366656&r1=366655&r2=366656&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp Sun Jul 21 07:07:54 2019
@@ -879,7 +879,8 @@ bool IRTranslator::translateLoad(const U
return true;
}
-
+ const MDNode *Ranges =
+ Regs.size() == 1 ? LI.getMetadata(LLVMContext::MD_range) : nullptr;
for (unsigned i = 0; i < Regs.size(); ++i) {
Register Addr;
MIRBuilder.materializeGEP(Addr, Base, OffsetTy, Offsets[i] / 8);
@@ -888,7 +889,7 @@ bool IRTranslator::translateLoad(const U
unsigned BaseAlign = getMemOpAlignment(LI);
auto MMO = MF->getMachineMemOperand(
Ptr, Flags, (MRI->getType(Regs[i]).getSizeInBits() + 7) / 8,
- MinAlign(BaseAlign, Offsets[i] / 8), AAMDNodes(), nullptr,
+ MinAlign(BaseAlign, Offsets[i] / 8), AAMDNodes(), Ranges,
LI.getSyncScopeID(), LI.getOrdering());
MIRBuilder.buildLoad(Regs[i], Addr, *MMO);
}
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll?rev=366656&r1=366655&r2=366656&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-irtranslator.ll Sun Jul 21 07:07:54 2019
@@ -351,7 +351,9 @@ define void @trunc(i64 %a) {
; CHECK: [[SUM2:%.*]]:_(s64) = G_ADD [[VAL1]], [[VAL2]]
; CHECK: [[VAL3:%[0-9]+]]:_(s64) = G_LOAD [[ADDR]](p0) :: (volatile load 8 from %ir.addr)
; CHECK: [[SUM3:%[0-9]+]]:_(s64) = G_ADD [[SUM2]], [[VAL3]]
-; CHECK: $x0 = COPY [[SUM3]]
+; CHECK: [[VAL4:%[0-9]+]]:_(s64) = G_LOAD [[ADDR]](p0) :: (load 8 from %ir.addr, !range !0)
+; CHECK: [[SUM4:%[0-9]+]]:_(s64) = G_ADD [[SUM3]], [[VAL4]]
+; CHECK: $x0 = COPY [[SUM4]]
; CHECK: RET_ReallyLR implicit $x0
define i64 @load(i64* %addr, i64 addrspace(42)* %addr42) {
%val1 = load i64, i64* %addr, align 16
@@ -361,7 +363,10 @@ define i64 @load(i64* %addr, i64 addrspa
%val3 = load volatile i64, i64* %addr
%sum3 = add i64 %sum2, %val3
- ret i64 %sum3
+
+ %val4 = load i64, i64* %addr, !range !0
+ %sum4 = add i64 %sum3, %val4
+ ret i64 %sum4
}
; CHECK-LABEL: name: store
@@ -2334,3 +2339,5 @@ define void @test_var_annotation(i8*, i8
call void @llvm.var.annotation(i8* %0, i8* %1, i8* %2, i32 %3)
ret void
}
+
+!0 = !{ i64 0, i64 2 }
More information about the llvm-commits
mailing list