mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-30 17:02:29 +00:00
Fixed the lost FastMathFlags in Reassociate optimization.
Reviewer: Hal Finkel. Differential Revision: https://reviews.llvm.org/D26957 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287695 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
abb5e38a8f
commit
f060e3f4bc
@ -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;
|
||||
|
14
test/Transforms/Reassociate/propagate-flags.ll
Normal file
14
test/Transforms/Reassociate/propagate-flags.ll
Normal file
@ -0,0 +1,14 @@
|
||||
; RUN: opt < %s -reassociate -S | FileCheck %s
|
||||
|
||||
; CHECK-LABEL: func
|
||||
; CHECK: fmul fast double
|
||||
; CHECK-NEXT: fmul fast double
|
||||
; CHECK-NEXT: ret
|
||||
|
||||
define double @func(double %a, double %b) {
|
||||
entry:
|
||||
%mul1 = fmul fast double %a, %a
|
||||
%mul2 = fmul fast double %b, %b
|
||||
%mul3 = fmul fast double %mul1, %mul2
|
||||
ret double %mul3
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user