aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-11-29 05:02:16 +0000
committerChris Lattner <sabre@nondot.org>2006-11-29 05:02:16 +0000
commit458cf462ef67e2169942775fac21e784bc26f208 (patch)
treea6c1c448824391aa5e20931965bbb9c8cf9014c6 /lib/Transforms
parent5b4c95810075e3bd8b92f7deeaeb7e06482c9371 (diff)
Implement Regression/Transforms/InstCombine/bswap-fold.ll,
folding seteq (bswap(x)), c -> seteq(x,bswap(c)) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32006 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 1e1db20ff2..92760b60ac 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -4664,7 +4664,7 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) {
break;
}
- // Simplify seteq and setne instructions...
+ // Simplify seteq and setne instructions with integer constant RHS.
if (I.isEquality()) {
bool isSetNE = I.getOpcode() == Instruction::SetNE;
@@ -4780,6 +4780,29 @@ Instruction *InstCombiner::visitSetCondInst(SetCondInst &I) {
}
default: break;
}
+ } else if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(Op0)) {
+ // Handle set{eq|ne} <intrinsic>, intcst.
+ switch (II->getIntrinsicID()) {
+ default: break;
+ case Intrinsic::bswap_i16: // seteq (bswap(x)), c -> seteq(x,bswap(c))
+ WorkList.push_back(II); // Dead?
+ I.setOperand(0, II->getOperand(1));
+ I.setOperand(1, ConstantInt::get(Type::UShortTy,
+ ByteSwap_16(CI->getZExtValue())));
+ return &I;
+ case Intrinsic::bswap_i32: // seteq (bswap(x)), c -> seteq(x,bswap(c))
+ WorkList.push_back(II); // Dead?
+ I.setOperand(0, II->getOperand(1));
+ I.setOperand(1, ConstantInt::get(Type::UIntTy,
+ ByteSwap_32(CI->getZExtValue())));
+ return &I;
+ case Intrinsic::bswap_i64: // seteq (bswap(x)), c -> seteq(x,bswap(c))
+ WorkList.push_back(II); // Dead?
+ I.setOperand(0, II->getOperand(1));
+ I.setOperand(1, ConstantInt::get(Type::ULongTy,
+ ByteSwap_64(CI->getZExtValue())));
+ return &I;
+ }
}
} else { // Not a SetEQ/SetNE
// If the LHS is a cast from an integral value of the same size,