diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/Reassociate.cpp | 24 |
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 |