aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar/Reassociate.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@codeaurora.org>2014-11-14 17:09:19 +0000
committerChad Rosier <mcrosier@codeaurora.org>2014-11-14 17:09:19 +0000
commitdf8f2a23cbaf0ff16cdc9d98fba10dc2b323985c (patch)
treef4a718396b9f4278dd0a8ccc7909cb59f02fb995 /llvm/lib/Transforms/Scalar/Reassociate.cpp
parent39e1cda45b4d93024e1f131e83278c47bd62899d (diff)
downloadllvm-df8f2a23cbaf0ff16cdc9d98fba10dc2b323985c.zip
llvm-df8f2a23cbaf0ff16cdc9d98fba10dc2b323985c.tar.gz
llvm-df8f2a23cbaf0ff16cdc9d98fba10dc2b323985c.tar.bz2
[Reassociate] Canonicalize the operands of all binary operators.
llvm-svn: 222008
Diffstat (limited to 'llvm/lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/Reassociate.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index 67659bb..30e9b88 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -2078,19 +2078,19 @@ void Reassociate::OptimizeInst(Instruction *I) {
if (Instruction *Res = canonicalizeNegConstExpr(I))
I = Res;
- // Commute floating point binary operators, to canonicalize the order of their
- // operands. This can potentially expose more CSE opportunities, and makes
- // writing other transformations simpler.
- if (I->getType()->isFloatingPointTy() || I->getType()->isVectorTy()) {
-
- if (I->isCommutative())
- canonicalizeOperands(I);
+ // Commute binary operators, to canonicalize the order of their operands.
+ // This can potentially expose more CSE opportunities, and makes writing other
+ // transformations simpler.
+ if (I->isCommutative())
+ canonicalizeOperands(I);
+
+ // Don't optimize vector instructions.
+ if (I->getType()->isVectorTy())
+ return;
- // Don't try to optimize vector instructions or anything that doesn't have
- // unsafe algebra.
- if (I->getType()->isVectorTy() || !I->hasUnsafeAlgebra())
- return;
- }
+ // Don't optimize floating point instructions that don't have unsafe algebra.
+ if (I->getType()->isFloatingPointTy() && !I->hasUnsafeAlgebra())
+ return;
// Do not reassociate boolean (i1) expressions. We want to preserve the
// original order of evaluation for short-circuited comparisons that