llvm.org GIT mirror llvm / c2d1b69
only factor from expressions whose uses are empty and whose base is the right expression type. This fixes PR5981. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93045 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 9 years ago
2 changed file(s) with 24 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
791791 Instruction *DummyInst = BinaryOperator::CreateAdd(MaxOccVal, MaxOccVal);
792792 SmallVector NewMulOps;
793793 for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
794 // Only try to remove factors from expressions we're allowed to.
795 BinaryOperator *BOp = dyn_cast(Ops[i].Op);
796 if (BOp == 0 || BOp->getOpcode() != Instruction::Mul || !BOp->use_empty())
797 continue;
798
794799 if (Value *V = RemoveFactorFromExpression(Ops[i].Op, MaxOccVal)) {
795800 NewMulOps.push_back(V);
796801 Ops.erase(Ops.begin()+i);
11
22
33 ; rdar://7507855
4 define fastcc i32 @test() nounwind {
4 define fastcc i32 @test1() nounwind {
55 entry:
66 %cond = select i1 undef, i32 1, i32 -1 ; [#uses=2]
77 br label %for.cond
1212 %add896 = sub i32 0, %cond ; [#uses=0]
1313 ret i32 undef
1414 }
15
16 ; PR5981
17 define i32 @test2() nounwind ssp {
18 entry:
19 %0 = load i32* undef, align 4
20 %1 = mul nsw i32 undef, %0
21 %2 = mul nsw i32 undef, %0
22 %3 = add nsw i32 undef, %1
23 %4 = add nsw i32 %3, %2
24 %5 = add nsw i32 %4, 4
25 %6 = shl i32 %0, 3 ; [#uses=1]
26 %7 = add nsw i32 %5, %6
27 br label %bb4.i9
28
29 bb4.i9: ; preds = %bb3.i7, %bb1.i25.i
30 %8 = add nsw i32 undef, %1
31 ret i32 0
32 }