mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[InstCombine] improve readability; NFC
CreateIntCast returns the input if its type matches, so need to duplicate that check.
This commit is contained in:
parent
7d9af1f0f7
commit
d9ffcf2505
@ -863,19 +863,15 @@ Instruction *InstCombiner::transformZExtICmp(ICmpInst *Cmp, ZExtInst &Zext,
|
|||||||
(Pred == ICmpInst::ICMP_SGT && Op1C->isAllOnesValue())) {
|
(Pred == ICmpInst::ICMP_SGT && Op1C->isAllOnesValue())) {
|
||||||
if (!DoTransform) return Cmp;
|
if (!DoTransform) return Cmp;
|
||||||
|
|
||||||
Value *In = Op0;
|
|
||||||
Value *ShAmt = ConstantInt::get(CmpOpType,
|
Value *ShAmt = ConstantInt::get(CmpOpType,
|
||||||
CmpOpType->getScalarSizeInBits() - 1);
|
CmpOpType->getScalarSizeInBits() - 1);
|
||||||
In = Builder.CreateLShr(In, ShAmt, In->getName() + ".lobit");
|
Value *Sh = Builder.CreateLShr(Op0, ShAmt, Op0->getName() + ".lobit");
|
||||||
if (CmpOpType != ZType)
|
Value *Cast = Builder.CreateIntCast(Sh, ZType, false /*ZExt*/);
|
||||||
In = Builder.CreateIntCast(In, ZType, false /*ZExt*/);
|
// Invert low bit if testing for positive.
|
||||||
|
if (Pred == ICmpInst::ICMP_SGT)
|
||||||
|
Cast = Builder.CreateXor(Cast, ConstantInt::get(CmpOpType, 1));
|
||||||
|
|
||||||
if (Pred == ICmpInst::ICMP_SGT) {
|
return replaceInstUsesWith(Zext, Cast);
|
||||||
Constant *One = ConstantInt::get(CmpOpType, 1);
|
|
||||||
In = Builder.CreateXor(In, One, In->getName() + ".not");
|
|
||||||
}
|
|
||||||
|
|
||||||
return replaceInstUsesWith(Zext, In);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// zext (X == 0) to i32 --> X^1 iff X has only the low bit set.
|
// zext (X == 0) to i32 --> X^1 iff X has only the low bit set.
|
||||||
|
Loading…
Reference in New Issue
Block a user