1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

I found a better place for this optz'n.

llvm-svn: 54877
This commit is contained in:
Nick Lewycky 2008-08-17 07:54:14 +00:00
parent 205be593b8
commit d797456fb4

View File

@ -5241,20 +5241,6 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
return new ICmpInst(I.getPredicate(), A, B); return new ICmpInst(I.getPredicate(), A, B);
} }
ConstantInt *CI2;
// (icmp u/s (xor A SignBit), C) -> (icmp s/u A, (xor C SignBit))
if (!I.isEquality() &&
match(Op0, m_Xor(m_Value(A), m_ConstantInt(CI2)))) {
if (CI2->getValue().isSignBit()) {
const APInt &SignBit = CI2->getValue();
ICmpInst::Predicate Pred = I.isSignedPredicate()
? I.getUnsignedPredicate()
: I.getSignedPredicate();
return new ICmpInst(Pred, A,
ConstantInt::get(CI->getValue() ^ SignBit));
}
}
// If we have a icmp le or icmp ge instruction, turn it into the appropriate // If we have a icmp le or icmp ge instruction, turn it into the appropriate
// icmp lt or icmp gt instruction. This allows us to rely on them being // icmp lt or icmp gt instruction. This allows us to rely on them being
// folded in the code below. // folded in the code below.
@ -5822,6 +5808,16 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI,
else else
return new ICmpInst(ICmpInst::ICMP_SLT, CompareVal, AddOne(RHS)); return new ICmpInst(ICmpInst::ICMP_SLT, CompareVal, AddOne(RHS));
} }
// (icmp u/s (xor A SignBit), C) -> (icmp s/u A, (xor C SignBit))
if (!ICI.isEquality() && XorCST->getValue().isSignBit()) {
const APInt &SignBit = XorCST->getValue();
ICmpInst::Predicate Pred = ICI.isSignedPredicate()
? ICI.getUnsignedPredicate()
: ICI.getSignedPredicate();
return new ICmpInst(Pred, LHSI->getOperand(0),
ConstantInt::get(RHSV ^ SignBit));
}
} }
break; break;
case Instruction::And: // (icmp pred (and X, AndCST), RHS) case Instruction::And: // (icmp pred (and X, AndCST), RHS)