1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

[InstCombine] fix constant to be signed for signed comparisons

This bug was introduced in r269728 and is the likely cause of many stage 2 ubsan bot failures.
I'll add a test in a follow-up commit assuming this fixes things properly.

llvm-svn: 269797
This commit is contained in:
Sanjay Patel 2016-05-17 18:38:55 +00:00
parent adbbf127ad
commit 2d43600215

View File

@ -3150,7 +3150,7 @@ static ICmpInst *canonicalizeCmpWithConstant(ICmpInst &I) {
// Increment or decrement the constant and set the new comparison predicate:
// ULE -> ULT ; UGE -> UGT ; SLE -> SLT ; SGE -> SGT
Constant *OneOrNegOne = ConstantInt::get(Op1Type, IsLE ? 1 : -1);
Constant *OneOrNegOne = ConstantInt::get(Op1Type, IsLE ? 1 : -1, IsSigned);
CmpInst::Predicate NewPred = IsLE ? ICmpInst::ICMP_ULT: ICmpInst::ICMP_UGT;
NewPred = IsSigned ? ICmpInst::getSignedPredicate(NewPred) : NewPred;
return new ICmpInst(NewPred, Op0, ConstantExpr::getAdd(Op1C, OneOrNegOne));