From 68a677ae5bacec56dff71cded32a376fe06b9fe0 Mon Sep 17 00:00:00 2001 From: Vyacheslav Klochkov Date: Tue, 22 Nov 2016 20:23:04 +0000 Subject: Fixed the lost FastMathFlags in Reassociate optimization. Reviewer: Hal Finkel. Differential Revision: https://reviews.llvm.org/D26957 llvm-svn: 287695 --- llvm/lib/Transforms/Scalar/Reassociate.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/Transforms/Scalar/Reassociate.cpp') 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(I)) + Builder.setFastMathFlags(FPI->getFastMathFlags()); + Value *V = buildMinimalMultiplyDAG(Builder, Factors); if (Ops.empty()) return V; -- cgit v1.2.3