summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-05-31 21:14:00 +0000
committerChris Lattner <sabre@nondot.org>2006-05-31 21:14:00 +0000
commit13d4ab4009822699f7546706bbc049cd8820d30a (patch)
tree986900d7d4f568e32385ad606c9174e74c0c63eb /lib
parent408a4061d8c119691c92fb8aa8c5dc2f9c05ccb0 (diff)
downloadllvm-13d4ab4009822699f7546706bbc049cd8820d30a.tar.gz
llvm-13d4ab4009822699f7546706bbc049cd8820d30a.tar.bz2
llvm-13d4ab4009822699f7546706bbc049cd8820d30a.tar.xz
Swap the order of operands created here. For +&|^, the order doesn't matter,
but for sub, it really does! Fix fixes a miscompilation of fibheap_cut in llvmgcc4. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28600 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 30a1de23aa..3a099af9e9 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -4437,7 +4437,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1,
Op0BO->getName());
InsertNewInstBefore(YS, I); // (Y << C)
Instruction *X =
- BinaryOperator::create(Op0BO->getOpcode(), YS, V1,
+ BinaryOperator::create(Op0BO->getOpcode(), V1, YS,
Op0BO->getOperand(0)->getName());
InsertNewInstBefore(X, I); // (X + (Y << C))
Constant *C2 = ConstantInt::getAllOnesValue(X->getType());
@@ -4445,6 +4445,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1,
return BinaryOperator::createAnd(X, C2);
}
+ // Turn (((X >> C)&CC) + Y) << C -> (X + (Y << C)) & (CC << C)
if (isLeftShift && Op0BO->getOperand(0)->hasOneUse() &&
match(Op0BO->getOperand(0),
m_And(m_Shr(m_Value(V1), m_Value(V2)),
@@ -4460,7 +4461,7 @@ Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1,
V1->getName()+".mask");
InsertNewInstBefore(XM, I); // X & (CC << C)
- return BinaryOperator::create(Op0BO->getOpcode(), YS, XM);
+ return BinaryOperator::create(Op0BO->getOpcode(), XM, YS);
}
break;