diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/Reassociate.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/Reassociate.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index 40c1e3717a2..181a324861e 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -1778,6 +1778,12 @@ Value *ReassociatePass::OptimizeMul(BinaryOperator *I, return nullptr; // All distinct factors, so nothing left for us to do. IRBuilder<> Builder(I); + // The reassociate transformation for FP operations is performed only + // if unsafe algebra is permitted by FastMathFlags. Propagate those flags + // to the newly generated operations. + if (auto FPI = dyn_cast<FPMathOperator>(I)) + Builder.setFastMathFlags(FPI->getFastMathFlags()); + Value *V = buildMinimalMultiplyDAG(Builder, Factors); if (Ops.empty()) return V; |