summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-11-02 03:50:32 +0000
committerChris Lattner <sabre@nondot.org>2004-11-02 03:50:32 +0000
commit96f66164798eb785b58e3fda947302458a62783c (patch)
treea11a1a8646e90a1e854fc5f277ac9c73638abb97
parent9df63b4e52a21daffec7bafd4b8cb3a6b2d654ed (diff)
downloadbcm5719-llvm-96f66164798eb785b58e3fda947302458a62783c.tar.gz
bcm5719-llvm-96f66164798eb785b58e3fda947302458a62783c.zip
* Rearrange code slightly
* Disable broken transforms for simplifying (setcc (cast X to larger), CI) where CC is not != or == llvm-svn: 17422
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index f8f0573395d..9274a4259cf 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2024,29 +2024,38 @@ Instruction *InstCombiner::visitSetCondInst(BinaryOperator &I) {
if (SrcTy == Type::BoolTy) SrcBits = 1;
unsigned DestBits = LHSI->getType()->getPrimitiveSize()*8;
if (LHSI->getType() == Type::BoolTy) DestBits = 1;
- if (SrcBits < DestBits) {
+ if (SrcBits < DestBits &&
+ // FIXME: Reenable the code below for < and >. However, we have
+ // to handle the cases when the source of the cast and the dest of
+ // the cast have different signs. e.g:
+ // (cast sbyte %X to uint) >u 255U -> X <s (sbyte)0
+ (I.getOpcode() == Instruction::SetEQ ||
+ I.getOpcode() == Instruction::SetNE)) {
// Check to see if the comparison is always true or false.
Constant *NewCst = ConstantExpr::getCast(CI, SrcTy);
if (ConstantExpr::getCast(NewCst, LHSI->getType()) != CI) {
- Constant *Min = ConstantIntegral::getMinValue(SrcTy);
- Constant *Max = ConstantIntegral::getMaxValue(SrcTy);
- Min = ConstantExpr::getCast(Min, LHSI->getType());
- Max = ConstantExpr::getCast(Max, LHSI->getType());
switch (I.getOpcode()) {
default: assert(0 && "unknown integer comparison");
+#if 0
+ case Instruction::SetLT: {
+ Constant *Max = ConstantIntegral::getMaxValue(SrcTy);
+ Max = ConstantExpr::getCast(Max, LHSI->getType());
+ return ReplaceInstUsesWith(I, ConstantExpr::getSetLT(Max, CI));
+ }
+ case Instruction::SetGT: {
+ Constant *Min = ConstantIntegral::getMinValue(SrcTy);
+ Min = ConstantExpr::getCast(Min, LHSI->getType());
+ return ReplaceInstUsesWith(I, ConstantExpr::getSetGT(Min, CI));
+ }
+#endif
case Instruction::SetEQ:
return ReplaceInstUsesWith(I, ConstantBool::False);
case Instruction::SetNE:
return ReplaceInstUsesWith(I, ConstantBool::True);
- case Instruction::SetLT:
- return ReplaceInstUsesWith(I, ConstantExpr::getSetLT(Max, CI));
- case Instruction::SetGT:
- return ReplaceInstUsesWith(I, ConstantExpr::getSetGT(Min, CI));
}
}
- return new SetCondInst(I.getOpcode(), LHSI->getOperand(0),
- ConstantExpr::getCast(CI, SrcTy));
+ return new SetCondInst(I.getOpcode(), LHSI->getOperand(0), NewCst);
}
}
break;
OpenPOWER on IntegriCloud