llvm.org GIT mirror llvm / ee2b7a4
Fix PR1907, a nasty miscompilation because instcombine didn't realize that ne & sgt was a signed comparison (it was only looking at whether the left compare was signed). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45937 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
2 changed file(s) with 17 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
34943494 ICmpInst::isSignedPredicate(LHSCC) ==
34953495 ICmpInst::isSignedPredicate(RHSCC))) {
34963496 // Ensure that the larger constant is on the RHS.
3497 ICmpInst::Predicate GT = ICmpInst::isSignedPredicate(LHSCC) ?
3498 ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
3497 ICmpInst::Predicate GT;
3498 if (ICmpInst::isSignedPredicate(LHSCC) ||
3499 (ICmpInst::isEquality(LHSCC) &&
3500 ICmpInst::isSignedPredicate(RHSCC)))
3501 GT = ICmpInst::ICMP_SGT;
3502 else
3503 GT = ICmpInst::ICMP_UGT;
3504
34993505 Constant *Cmp = ConstantExpr::getICmp(GT, LHSCst, RHSCst);
35003506 ICmpInst *LHS = cast(Op0);
35013507 if (cast(Cmp)->getZExtValue()) {
0 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep and
1 ; PR1907
2
3 define i1 @test(i32 %c84.17) {
4 %tmp2696 = icmp ne i32 %c84.17, 34 ; [#uses=2]
5 %tmp2699 = icmp sgt i32 %c84.17, -1 ; [#uses=1]
6 %tmp2703 = and i1 %tmp2696, %tmp2699 ; [#uses=1]
7 ret i1 %tmp2703
8 }