llvm.org GIT mirror llvm / c2695eb
Revert 72493 and replace it with a more conservative fix, for now: don't rewrite the comparison if there is any implicit extension or truncation on the induction variable. I'm planning for IVUsers to eventually take over some of the work of this code, and for it to be generalized. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72496 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
2 changed file(s) with 33 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
19921992 ValidScale(!CommonExprs->isZero(), Scale, UsersToProcess))
19931993 continue;
19941994
1995 // Avoid rewriting the compare instruction with an iv which has
1996 // implicit extension or truncation built into it.
1997 // TODO: This is over-conservative.
1998 if (SE->getTypeSizeInBits(CondUse->getOffset()->getType()) != TyBits)
1999 continue;
2000
19952001 // If scale is negative, use swapped predicate unless it's testing
19962002 // for equality.
19972003 if (Scale < 0 && !Cond->isEquality())
20042010 ConstantInt *CI = ConstantInt::get(NewCmpIntTy, NewCmpVal);
20052011 NewCmpRHS = ConstantExpr::getIntToPtr(CI, NewCmpTy);
20062012 }
2007 NewOffset = CondUse->getOffset();
2008 if (CondUse->isSigned())
2009 NewOffset = SE->getNoopOrSignExtend(CondUse->getOffset(), NewCmpTy);
2010 else
2011 NewOffset = SE->getNoopOrZeroExtend(CondUse->getOffset(), NewCmpTy);
20122013 NewOffset = TyBits == NewTyBits
2013 ? SE->getMulExpr(NewOffset,
2014 ? SE->getMulExpr(CondUse->getOffset(),
20142015 SE->getConstant(ConstantInt::get(CmpTy, Scale)))
20152016 : SE->getConstant(ConstantInt::get(NewCmpIntTy,
2016 cast(NewOffset)->getValue()
2017 cast(CondUse->getOffset())->getValue()
20172018 ->getSExtValue()*Scale));
20182019 break;
20192020 }
3030 %indvar.next689 = add i64 %indvar688, 1 ; [#uses=1]
3131 br i1 %phitmp654, label %for.cond.i.preheader, label %if.end
3232 }
33
34 define void @promote(%struct.dumperinfo* %di) nounwind {
35 entry:
36 br label %if.end
37
38 if.end: ; preds = %if.end52, %entry
39 br label %for.cond.i.preheader
40
41 for.cond.i.preheader: ; preds = %if.end52, %if.end
42 %indvar688 = phi i32 [ 0, %if.end ], [ %indvar.next689, %if.end52 ] ; [#uses=3]
43 %tmp690 = shl i32 %indvar688, 12 ; [#uses=1]
44 %pa.0642 = add i32 %tmp690, 0 ; [#uses=1]
45 %tmp692693 = add i32 %indvar688, 1 ; [#uses=1]
46 %phitmp = sext i32 %tmp692693 to i64 ; [#uses=1]
47 br i1 false, label %if.end52, label %land.lhs.true.i
48
49 land.lhs.true.i: ; preds = %for.cond.i.preheader
50 %shr2.i = lshr i32 %pa.0642, 18 ; [#uses=0]
51 unreachable
52
53 if.end52: ; preds = %for.cond.i.preheader
54 %phitmp654 = icmp ult i64 %phitmp, 512 ; [#uses=1]
55 %indvar.next689 = add i32 %indvar688, 1 ; [#uses=1]
56 br i1 %phitmp654, label %for.cond.i.preheader, label %if.end
57 }