aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Criswell <criswell@uiuc.edu>2004-08-11 01:23:22 +0000
committerJohn Criswell <criswell@uiuc.edu>2004-08-11 01:23:22 +0000
commitef095995c78f75bae03267f8237f67499e84ce03 (patch)
tree4479463cb344307e95a315088dfc50e3e9aceb82
parent841e6949d74b66fd944d17613de2547bc1982e41 (diff)
downloadllvm-ef095995c78f75bae03267f8237f67499e84ce03.zip
llvm-ef095995c78f75bae03267f8237f67499e84ce03.tar.gz
llvm-ef095995c78f75bae03267f8237f67499e84ce03.tar.bz2
Merged in revision 1.239 from mainline.
llvm-svn: 15640
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp43
1 files changed, 21 insertions, 22 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index bf0f0e8..97cdc11 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1392,34 +1392,33 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
// setcc's with boolean values can always be turned into bitwise operations
if (Ty == Type::BoolTy) {
- // If this is <, >, or !=, we can change this into a simple xor instruction
- if (!isTrueWhenEqual(I))
- return BinaryOperator::createXor(Op0, Op1);
-
- // Otherwise we need to make a temporary intermediate instruction and insert
- // it into the instruction stream. This is what we are after:
- //
- // seteq bool %A, %B -> ~(A^B)
- // setle bool %A, %B -> ~A | B
- // setge bool %A, %B -> A | ~B
- //
- if (I.getOpcode() == Instruction::SetEQ) { // seteq case
+ switch (I.getOpcode()) {
+ default: assert(0 && "Invalid setcc instruction!");
+ case Instruction::SetEQ: { // seteq bool %A, %B -> ~(A^B)
Instruction *Xor = BinaryOperator::createXor(Op0, Op1, I.getName()+"tmp");
InsertNewInstBefore(Xor, I);
return BinaryOperator::createNot(Xor);
}
+ case Instruction::SetNE:
+ return BinaryOperator::createXor(Op0, Op1);
- // Handle the setXe cases...
- assert(I.getOpcode() == Instruction::SetGE ||
- I.getOpcode() == Instruction::SetLE);
-
- if (I.getOpcode() == Instruction::SetGE)
+ case Instruction::SetGT:
+ std::swap(Op0, Op1); // Change setgt -> setlt
+ // FALL THROUGH
+ case Instruction::SetLT: { // setlt bool A, B -> ~X & Y
+ Instruction *Not = BinaryOperator::createNot(Op0, I.getName()+"tmp");
+ InsertNewInstBefore(Not, I);
+ return BinaryOperator::createAnd(Not, Op1);
+ }
+ case Instruction::SetGE:
std::swap(Op0, Op1); // Change setge -> setle
-
- // Now we just have the SetLE case.
- Instruction *Not = BinaryOperator::createNot(Op0, I.getName()+"tmp");
- InsertNewInstBefore(Not, I);
- return BinaryOperator::createOr(Not, Op1);
+ // FALL THROUGH
+ case Instruction::SetLE: { // setle bool %A, %B -> ~A | B
+ Instruction *Not = BinaryOperator::createNot(Op0, I.getName()+"tmp");
+ InsertNewInstBefore(Not, I);
+ return BinaryOperator::createOr(Not, Op1);
+ }
+ }
}
// See if we are doing a comparison between a constant and an instruction that