llvm.org GIT mirror llvm / abf7067
Fix my previous patch to handle a degenerate case that the llvm-gcc bootstrap buildbot tripped over. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121674 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 8 years ago
2 changed file(s) with 39 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
18151815 ICI->replaceAllUsesWith(C);
18161816 ICI->eraseFromParent();
18171817 }
1818 // BB is now empty, so it is likely to simplify away.
1819 return SimplifyCFG(BB) | true;
1820 }
1821
1822 // Ok, the block is reachable from the default dest. If the constant we're
1823 // comparing exists in one of the other edges, then we can constant fold ICI
1824 // and zap it.
1825 if (SI->findCaseValue(Cst) != 0) {
1826 Value *V;
1827 if (ICI->getPredicate() == ICmpInst::ICMP_EQ)
1828 V = ConstantInt::getFalse(BB->getContext());
1829 else
1830 V = ConstantInt::getTrue(BB->getContext());
1831
1832 ICI->replaceAllUsesWith(V);
1833 ICI->eraseFromParent();
18181834 // BB is now empty, so it is likely to simplify away.
18191835 return SimplifyCFG(BB) | true;
18201836 }
8787 ; CHECK: ]
8888 }
8989
90 define i32 @test5(i8 zeroext %c) nounwind ssp noredzone {
91 entry:
92 switch i8 %c, label %lor.rhs [
93 i8 62, label %lor.end
94 i8 34, label %lor.end
95 i8 92, label %lor.end
96 ]
97
98 lor.rhs: ; preds = %entry
99 %V = icmp eq i8 %c, 92
100 br label %lor.end
101
102 lor.end: ; preds = %entry, %entry, %entry, %lor.rhs
103 %0 = phi i1 [ true, %entry ], [ %V, %lor.rhs ], [ true, %entry ], [ true, %entry ]
104 %lor.ext = zext i1 %0 to i32
105 ret i32 %lor.ext
106 ; CHECK: @test5
107 ; CHECK: switch i8 %c, label %lor.rhs [
108 ; CHECK: i8 62, label %lor.end
109 ; CHECK: i8 34, label %lor.end
110 ; CHECK: i8 92, label %lor.end
111 ; CHECK: ]
112 }