mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-26 21:56:11 +00:00
Revert r314017 '[InstCombine] Simplify check for RHS being a splat constant in foldICmpUsingKnownBits by just checking Op1Min==Op1Max rather than going through m_APInt.'
This reverts r314017 and similar code added in later commits. It seems to not work for pointer compares and is causing a bot failure for the last several days. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314360 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
27f9857973
commit
f1654930d1
@ -4200,14 +4200,15 @@ Instruction *InstCombiner::foldICmpUsingKnownBits(ICmpInst &I) {
|
||||
if (Op1Min == Op0Max) // A <u B -> A != B if max(A) == min(B)
|
||||
return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
|
||||
|
||||
if (Op1Min == Op1Max) {
|
||||
const APInt *CmpC;
|
||||
if (match(Op1, m_APInt(CmpC))) {
|
||||
// A <u C -> A == C-1 if min(A)+1 == C
|
||||
if (Op1Min == Op0Min + 1)
|
||||
if (*CmpC == Op0Min + 1)
|
||||
return new ICmpInst(ICmpInst::ICMP_EQ, Op0,
|
||||
ConstantInt::get(Op0->getType(), Op1Min - 1));
|
||||
ConstantInt::get(Op1->getType(), *CmpC - 1));
|
||||
// X <u C --> X == 0, if the number of zero bits in the bottom of X
|
||||
// exceeds the log2 of C.
|
||||
if (Op0Known.countMinTrailingZeros() >= Op1Min.ceilLogBase2())
|
||||
if (Op0Known.countMinTrailingZeros() >= CmpC->ceilLogBase2())
|
||||
return new ICmpInst(ICmpInst::ICMP_EQ, Op0,
|
||||
Constant::getNullValue(Op1->getType()));
|
||||
}
|
||||
@ -4221,45 +4222,50 @@ Instruction *InstCombiner::foldICmpUsingKnownBits(ICmpInst &I) {
|
||||
if (Op1Max == Op0Min) // A >u B -> A != B if min(A) == max(B)
|
||||
return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
|
||||
|
||||
if (Op1Min == Op1Max) {
|
||||
const APInt *CmpC;
|
||||
if (match(Op1, m_APInt(CmpC))) {
|
||||
// A >u C -> A == C+1 if max(a)-1 == C
|
||||
if (Op1Min == Op0Max - 1)
|
||||
if (*CmpC == Op0Max - 1)
|
||||
return new ICmpInst(ICmpInst::ICMP_EQ, Op0,
|
||||
ConstantInt::get(Op1->getType(), Op1Min + 1));
|
||||
ConstantInt::get(Op1->getType(), *CmpC + 1));
|
||||
// X >u C --> X != 0, if the number of zero bits in the bottom of X
|
||||
// exceeds the log2 of C.
|
||||
if (Op0Known.countMinTrailingZeros() >= Op1Min.getActiveBits())
|
||||
if (Op0Known.countMinTrailingZeros() >= CmpC->getActiveBits())
|
||||
return new ICmpInst(ICmpInst::ICMP_NE, Op0,
|
||||
Constant::getNullValue(Op1->getType()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ICmpInst::ICMP_SLT:
|
||||
case ICmpInst::ICMP_SLT: {
|
||||
if (Op0Max.slt(Op1Min)) // A <s B -> true if max(A) < min(C)
|
||||
return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType()));
|
||||
if (Op0Min.sge(Op1Max)) // A <s B -> false if min(A) >= max(C)
|
||||
return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType()));
|
||||
if (Op1Min == Op0Max) // A <s B -> A != B if max(A) == min(B)
|
||||
return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
|
||||
if (Op1Min == Op1Max) { // Constant RHS
|
||||
if (Op1Min == Op0Min + 1) // A <s C -> A == C-1 if min(A)+1 == C
|
||||
const APInt *CmpC;
|
||||
if (match(Op1, m_APInt(CmpC))) {
|
||||
if (*CmpC == Op0Min + 1) // A <s C -> A == C-1 if min(A)+1 == C
|
||||
return new ICmpInst(ICmpInst::ICMP_EQ, Op0,
|
||||
ConstantInt::get(Op1->getType(), Op1Min - 1));
|
||||
ConstantInt::get(Op1->getType(), *CmpC - 1));
|
||||
}
|
||||
break;
|
||||
case ICmpInst::ICMP_SGT:
|
||||
}
|
||||
case ICmpInst::ICMP_SGT: {
|
||||
if (Op0Min.sgt(Op1Max)) // A >s B -> true if min(A) > max(B)
|
||||
return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType()));
|
||||
if (Op0Max.sle(Op1Min)) // A >s B -> false if max(A) <= min(B)
|
||||
return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType()));
|
||||
if (Op1Max == Op0Min) // A >s B -> A != B if min(A) == max(B)
|
||||
return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
|
||||
if (Op1Min == Op1Max) { // Constant RHS
|
||||
if (Op1Min == Op0Max - 1) // A >s C -> A == C+1 if max(A)-1 == C
|
||||
const APInt *CmpC;
|
||||
if (match(Op1, m_APInt(CmpC))) {
|
||||
if (*CmpC == Op0Max - 1) // A >s C -> A == C+1 if max(A)-1 == C
|
||||
return new ICmpInst(ICmpInst::ICMP_EQ, Op0,
|
||||
ConstantInt::get(Op1->getType(), Op1Min + 1));
|
||||
ConstantInt::get(Op1->getType(), *CmpC + 1));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ICmpInst::ICMP_SGE:
|
||||
assert(!isa<ConstantInt>(Op1) && "ICMP_SGE with ConstantInt not folded!");
|
||||
if (Op0Min.sge(Op1Max)) // A >=s B -> true if min(A) >= max(B)
|
||||
|
Loading…
x
Reference in New Issue
Block a user