diff options
| author | Owen Anderson <resistor@mac.com> | 2014-01-16 21:07:52 +0000 | 
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2014-01-16 21:07:52 +0000 | 
| commit | 4557a156e382fdd829a390ee9b41a1db7a8d6f9f (patch) | |
| tree | 6b5da93a2f3d3955f4e60ef96d3a0897c0a94b41 /llvm | |
| parent | e8537fc7e0ac25c9438ab92829203a0364f78f6a (diff) | |
| download | bcm5719-llvm-4557a156e382fdd829a390ee9b41a1db7a8d6f9f.tar.gz bcm5719-llvm-4557a156e382fdd829a390ee9b41a1db7a8d6f9f.zip  | |
Fix an instance where we would drop fast math flags when performing an fdiv to reciprocal multiply transformation.
llvm-svn: 199425
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | 4 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/fdiv.ll | 8 | 
2 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 94461c5f84a..f61d82340b5 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -1050,8 +1050,10 @@ Instruction *InstCombiner::visitFDiv(BinaryOperator &I) {      }      // X / C => X * 1/C -    if (Instruction *T = CvtFDivConstToReciprocal(Op0, Op1C, AllowReciprocal)) +    if (Instruction *T = CvtFDivConstToReciprocal(Op0, Op1C, AllowReciprocal)) { +      T->copyFastMathFlags(&I);        return T; +    }      return 0;    } diff --git a/llvm/test/Transforms/InstCombine/fdiv.ll b/llvm/test/Transforms/InstCombine/fdiv.ll index 1edbc5ecd60..c3aabd78666 100644 --- a/llvm/test/Transforms/InstCombine/fdiv.ll +++ b/llvm/test/Transforms/InstCombine/fdiv.ll @@ -23,3 +23,11 @@ define float @test3(float %x) nounwind readnone ssp {  ; CHECK-LABEL: @test3(  ; CHECK-NEXT: fdiv float %x, 0x36A0000000000000  } + +define float @test4(float %x) nounwind readnone ssp { +  %div = fdiv fast float %x, 8.0 +  ret float %div + +; CHECK-LABEL: @test4( +; CHECK-NEXT: fmul fast float %x, 1.250000e-01 +}  | 

