forked from OSchip/llvm-project
[InstCombine] Simplify check for RHS being a splat constant in foldICmpUsingKnownBits by just checking Op1Min==Op1Max rather than going through m_APInt.
llvm-svn: 314017
This commit is contained in:
parent
2c9b7d7894
commit
5b35b68785
|
@ -4223,12 +4223,11 @@ Instruction *InstCombiner::foldICmpUsingKnownBits(ICmpInst &I) {
|
||||||
if (Op1Min == Op0Max) // A <u B -> A != B if max(A) == min(B)
|
if (Op1Min == Op0Max) // A <u B -> A != B if max(A) == min(B)
|
||||||
return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
|
return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
|
||||||
|
|
||||||
const APInt *CmpC;
|
if (Op1Min == Op1Max) {
|
||||||
if (match(Op1, m_APInt(CmpC))) {
|
|
||||||
// A <u C -> A == C-1 if min(A)+1 == C
|
// A <u C -> A == C-1 if min(A)+1 == C
|
||||||
if (Op1Max == Op0Min + 1)
|
if (Op1Min == Op0Min + 1)
|
||||||
return new ICmpInst(ICmpInst::ICMP_EQ, Op0,
|
return new ICmpInst(ICmpInst::ICMP_EQ, Op0,
|
||||||
ConstantInt::get(Op0->getType(), *CmpC - 1));
|
ConstantInt::get(Op0->getType(), Op1Min - 1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4240,12 +4239,11 @@ Instruction *InstCombiner::foldICmpUsingKnownBits(ICmpInst &I) {
|
||||||
if (Op1Max == Op0Min) // A >u B -> A != B if min(A) == max(B)
|
if (Op1Max == Op0Min) // A >u B -> A != B if min(A) == max(B)
|
||||||
return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
|
return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
|
||||||
|
|
||||||
const APInt *CmpC;
|
if (Op1Min == Op1Max) {
|
||||||
if (match(Op1, m_APInt(CmpC))) {
|
|
||||||
// A >u C -> A == C+1 if max(a)-1 == C
|
// A >u C -> A == C+1 if max(a)-1 == C
|
||||||
if (*CmpC == Op0Max - 1)
|
if (Op1Min == Op0Max - 1)
|
||||||
return new ICmpInst(ICmpInst::ICMP_EQ, Op0,
|
return new ICmpInst(ICmpInst::ICMP_EQ, Op0,
|
||||||
ConstantInt::get(Op1->getType(), *CmpC + 1));
|
ConstantInt::get(Op1->getType(), Op1Min + 1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue