mirror of
https://github.com/RPCSX/llvm.git
synced 2025-05-13 10:56:01 +00: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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269797 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8ae1501586
commit
0353bb1421
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user