[llvm] r265097 - Fix Sub-register Rewriting in Aggressive Anti-Dependence Breaker
Chuang-Yu Cheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 31 19:05:33 PDT 2016
Author: cycheng
Date: Thu Mar 31 21:05:29 2016
New Revision: 265097
URL: http://llvm.org/viewvc/llvm-project?rev=265097&view=rev
Log:
Fix Sub-register Rewriting in Aggressive Anti-Dependence Breaker
Previously, HandleLastUse would delete RegRef information for sub-registers
if they were dead even if their corresponding super-register were still live.
If the super-register were later renamed, then the definitions of the
sub-register would not be updated appropriately. This patch alters the
behavior so that RegInfo information for sub-registers is only deleted when
the sub-register and super-register are both dead.
This resolves PR26775. This is the mirror image of Hal's r227311 commit.
Author: Tom Jablin (tjablin)
Reviewers: kbarton uweigand nemanjai hfinkel
http://reviews.llvm.org/D18448
Added:
llvm/trunk/test/CodeGen/PowerPC/aggressive-anti-dep-breaker-subreg.ll
Modified:
llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp
Modified: llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp?rev=265097&r1=265096&r2=265097&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp (original)
+++ llvm/trunk/lib/CodeGen/AggressiveAntiDepBreaker.cpp Thu Mar 31 21:05:29 2016
@@ -312,19 +312,22 @@ void AggressiveAntiDepBreaker::HandleLas
DEBUG(if (header) {
dbgs() << header << TRI->getName(Reg); header = nullptr; });
DEBUG(dbgs() << "->g" << State->GetGroup(Reg) << tag);
- }
- // Repeat for subregisters.
- for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs) {
- unsigned SubregReg = *SubRegs;
- if (!State->IsLive(SubregReg)) {
- KillIndices[SubregReg] = KillIdx;
- DefIndices[SubregReg] = ~0u;
- RegRefs.erase(SubregReg);
- State->LeaveGroup(SubregReg);
- DEBUG(if (header) {
- dbgs() << header << TRI->getName(Reg); header = nullptr; });
- DEBUG(dbgs() << " " << TRI->getName(SubregReg) << "->g" <<
- State->GetGroup(SubregReg) << tag);
+ // Repeat for subregisters. Note that we only do this if the superregister
+ // was not live because otherwise, regardless whether we have an explicit
+ // use of the subregister, the subregister's contents are needed for the
+ // uses of the superregister.
+ for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs) {
+ unsigned SubregReg = *SubRegs;
+ if (!State->IsLive(SubregReg)) {
+ KillIndices[SubregReg] = KillIdx;
+ DefIndices[SubregReg] = ~0u;
+ RegRefs.erase(SubregReg);
+ State->LeaveGroup(SubregReg);
+ DEBUG(if (header) {
+ dbgs() << header << TRI->getName(Reg); header = nullptr; });
+ DEBUG(dbgs() << " " << TRI->getName(SubregReg) << "->g" <<
+ State->GetGroup(SubregReg) << tag);
+ }
}
}
Added: llvm/trunk/test/CodeGen/PowerPC/aggressive-anti-dep-breaker-subreg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/aggressive-anti-dep-breaker-subreg.ll?rev=265097&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/aggressive-anti-dep-breaker-subreg.ll (added)
+++ llvm/trunk/test/CodeGen/PowerPC/aggressive-anti-dep-breaker-subreg.ll Thu Mar 31 21:05:29 2016
@@ -0,0 +1,24 @@
+; RUN: llc %s -mtriple=powerpc64-unknown-linux-gnu -O2 -o - -optimize-regalloc=false -regalloc=fast | FileCheck %s
+
+declare void @func(i8*, i64, i64)
+
+define void @test(i8* %context, i32** %elementArrayPtr, i32 %value) {
+entry:
+ %cmp = icmp eq i32 %value, 0
+ br i1 %cmp, label %lreturn, label %lnext
+
+lnext:
+ %elementArray = load i32*, i32** %elementArrayPtr, align 8
+; CHECK: lwz [[LDREG:[0-9]+]], 124(1) # 4-byte Folded Reload
+; CHECK: # implicit-def: %X[[TEMPREG:[0-9]+]]
+ %element = load i32, i32* %elementArray, align 4
+; CHECK: mr [[TEMPREG]], [[LDREG]]
+; CHECK: clrldi 4, [[TEMPREG]], 32
+ %element.ext = zext i32 %element to i64
+ %value.ext = zext i32 %value to i64
+ call void @func(i8* %context, i64 %value.ext, i64 %element.ext)
+ br label %lreturn
+
+lreturn:
+ ret void
+}
More information about the llvm-commits
mailing list