summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/Reassociate.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-05-08 21:33:47 +0000
committerChris Lattner <sabre@nondot.org>2005-05-08 21:33:47 +0000
commit6f156856ca23394122f39d92fe74eec40a1f7c27 (patch)
treededc08b7db5dc3f44f751530ce467ca3e205849e /lib/Transforms/Scalar/Reassociate.cpp
parentf33151aff008c40eec6435ddb7a5c9017b6acef9 (diff)
downloadllvm-6f156856ca23394122f39d92fe74eec40a1f7c27.tar.gz
llvm-6f156856ca23394122f39d92fe74eec40a1f7c27.tar.bz2
llvm-6f156856ca23394122f39d92fe74eec40a1f7c27.tar.xz
Bail out earlier
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21786 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r--lib/Transforms/Scalar/Reassociate.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp
index 6958903226..592df535af 100644
--- a/lib/Transforms/Scalar/Reassociate.cpp
+++ b/lib/Transforms/Scalar/Reassociate.cpp
@@ -341,10 +341,6 @@ static Value *NegateValue(Value *V, Instruction *BI) {
/// only used by an add, transform this into (X+(0-Y)) to promote better
/// reassociation.
static Instruction *BreakUpSubtract(Instruction *Sub) {
- // Reject cases where it is pointless to do this.
- if (Sub->getType()->isFloatingPoint())
- return 0; // Floating point adds are not associative.
-
// Don't bother to break this up unless either the LHS is an associable add or
// if this is only used by one.
if (!isReassociableOp(Sub->getOperand(0), Instruction::Add) &&
@@ -560,6 +556,10 @@ static void PrintOps(unsigned Opcode, const std::vector<ValueEntry> &Ops,
/// reassociating them as we go.
void Reassociate::ReassociateBB(BasicBlock *BB) {
for (BasicBlock::iterator BI = BB->begin(); BI != BB->end(); ++BI) {
+ // Reject cases where it is pointless to do this.
+ if (!isa<BinaryOperator>(BI) || BI->getType()->isFloatingPoint())
+ continue; // Floating point ops are not associative.
+
// If this is a subtract instruction which is not already in negate form,
// see if we can convert it to X+-Y.
if (BI->getOpcode() == Instruction::Sub) {