mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Revert "indvars: sink truncates outside the loop."
This reverts commit r198654. One of the bots reported a SciMark failure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198659 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a16f1ce2d9
commit
2352abb7c6
@ -883,8 +883,6 @@ const SCEVAddRecExpr *WidenIV::GetWideRecurrence(Instruction *NarrowUse) {
|
|||||||
/// This IV user cannot be widen. Replace this use of the original narrow IV
|
/// This IV user cannot be widen. Replace this use of the original narrow IV
|
||||||
/// with a truncation of the new wide IV to isolate and eliminate the narrow IV.
|
/// with a truncation of the new wide IV to isolate and eliminate the narrow IV.
|
||||||
static void truncateIVUse(NarrowIVDefUse DU, DominatorTree *DT) {
|
static void truncateIVUse(NarrowIVDefUse DU, DominatorTree *DT) {
|
||||||
DEBUG(dbgs() << "INDVARS: Truncate IV " << *DU.WideDef
|
|
||||||
<< " for user " << *DU.NarrowUse << "\n");
|
|
||||||
IRBuilder<> Builder(getInsertPointForUses(DU.NarrowUse, DU.NarrowDef, DT));
|
IRBuilder<> Builder(getInsertPointForUses(DU.NarrowUse, DU.NarrowDef, DT));
|
||||||
Value *Trunc = Builder.CreateTrunc(DU.WideDef, DU.NarrowDef->getType());
|
Value *Trunc = Builder.CreateTrunc(DU.WideDef, DU.NarrowDef->getType());
|
||||||
DU.NarrowUse->replaceUsesOfWith(DU.NarrowDef, Trunc);
|
DU.NarrowUse->replaceUsesOfWith(DU.NarrowDef, Trunc);
|
||||||
@ -895,27 +893,10 @@ static void truncateIVUse(NarrowIVDefUse DU, DominatorTree *DT) {
|
|||||||
Instruction *WidenIV::WidenIVUse(NarrowIVDefUse DU, SCEVExpander &Rewriter) {
|
Instruction *WidenIV::WidenIVUse(NarrowIVDefUse DU, SCEVExpander &Rewriter) {
|
||||||
|
|
||||||
// Stop traversing the def-use chain at inner-loop phis or post-loop phis.
|
// Stop traversing the def-use chain at inner-loop phis or post-loop phis.
|
||||||
if (PHINode *UsePhi = dyn_cast<PHINode>(DU.NarrowUse)) {
|
if (isa<PHINode>(DU.NarrowUse) &&
|
||||||
if (LI->getLoopFor(UsePhi->getParent()) != L) {
|
LI->getLoopFor(DU.NarrowUse->getParent()) != L) {
|
||||||
// For LCSSA phis, sink the truncate outside the loop.
|
truncateIVUse(DU, DT);
|
||||||
// After SimplifyCFG most loop exit targets have a single predecessor.
|
return 0;
|
||||||
// Otherwise fall back to a truncate within the loop.
|
|
||||||
if (UsePhi->getNumOperands() != 1)
|
|
||||||
truncateIVUse(DU, DT);
|
|
||||||
else {
|
|
||||||
PHINode *WidePhi =
|
|
||||||
PHINode::Create(DU.WideDef->getType(), 1, UsePhi->getName() + ".wide",
|
|
||||||
UsePhi);
|
|
||||||
WidePhi->addIncoming(DU.WideDef, UsePhi->getIncomingBlock(0));
|
|
||||||
IRBuilder<> Builder(WidePhi->getParent()->getFirstInsertionPt());
|
|
||||||
Value *Trunc = Builder.CreateTrunc(WidePhi, DU.NarrowDef->getType());
|
|
||||||
UsePhi->replaceAllUsesWith(Trunc);
|
|
||||||
DeadInsts.push_back(UsePhi);
|
|
||||||
DEBUG(dbgs() << "INDVARS: Widen lcssa phi " << *UsePhi
|
|
||||||
<< " to " << *WidePhi << "\n");
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Our raison d'etre! Eliminate sign and zero extension.
|
// Our raison d'etre! Eliminate sign and zero extension.
|
||||||
if (IsSigned ? isa<SExtInst>(DU.NarrowUse) : isa<ZExtInst>(DU.NarrowUse)) {
|
if (IsSigned ? isa<SExtInst>(DU.NarrowUse) : isa<ZExtInst>(DU.NarrowUse)) {
|
||||||
|
@ -7,11 +7,10 @@ target triple = "x86_64-apple-darwin"
|
|||||||
; Only one phi now.
|
; Only one phi now.
|
||||||
; CHECK: phi
|
; CHECK: phi
|
||||||
; CHECK-NOT: phi
|
; CHECK-NOT: phi
|
||||||
; One trunc for the gep.
|
; We now get 2 trunc, one for the gep and one for the lcssa phi.
|
||||||
; CHECK: trunc i64 %indvars.iv to i32
|
; CHECK: trunc i64 %indvars.iv to i32
|
||||||
; One trunc for the dummy() call.
|
; CHECK: trunc i64 %indvars.iv to i32
|
||||||
; CHECK-LABEL: exit24:
|
; CHECK-LABEL: B24:
|
||||||
; CHECK: trunc i64 {{.*}}lcssa.wide to i32
|
|
||||||
define void @sloop(i32* %a) {
|
define void @sloop(i32* %a) {
|
||||||
Prologue:
|
Prologue:
|
||||||
br i1 undef, label %B18, label %B6
|
br i1 undef, label %B18, label %B6
|
||||||
|
Loading…
x
Reference in New Issue
Block a user