revert r339608 - [SimplifyLibCalls] don't drop fast-math-flags on trig reflection...
authorSanjay Patel <spatel@rotateright.com>
Mon, 13 Aug 2018 20:20:38 +0000 (20:20 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 13 Aug 2018 20:20:38 +0000 (20:20 +0000)
Can't set the builder flags without knowing this is an FPMathOperator. I'll add a test
for that and try again.

llvm-svn: 339609

llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/cos-1.ll

index 599d50b..eda3f05 100644 (file)
@@ -1124,9 +1124,7 @@ Value *LibCallSimplifier::optimizeCAbs(CallInst *CI, IRBuilder<> &B) {
 
 static Value *optimizeTrigReflections(CallInst *Call, LibFunc Func,
                                       IRBuilder<> &B) {
-  IRBuilder<>::FastMathFlagGuard Guard(B);
-  B.setFastMathFlags(Call->getFastMathFlags());
-  
+  // FIXME: This drops FMF.
   // TODO: Add tan() and other calls.
   // TODO: Can this be shared to also handle LLVM intrinsics?
   Value *X;
index 8c9a5d8..daa193b 100644 (file)
@@ -40,7 +40,7 @@ define float @cosf_negated_arg(float %x) {
 
 define float @cosf_negated_arg_FMF(float %x) {
 ; ANY-LABEL: @cosf_negated_arg_FMF(
-; ANY-NEXT:    [[COS:%.*]] = call reassoc nnan float @cosf(float [[X:%.*]])
+; ANY-NEXT:    [[COS:%.*]] = call float @cosf(float [[X:%.*]])
 ; ANY-NEXT:    ret float [[COS]]
 ;
   %neg = fsub float -0.0, %x
@@ -72,17 +72,6 @@ define float @sinf_negated_arg(float %x) {
   ret float %r
 }
 
-define float @sinf_negated_arg_FMF(float %x) {
-; ANY-LABEL: @sinf_negated_arg_FMF(
-; ANY-NEXT:    [[SIN:%.*]] = call nnan afn float @sinf(float [[X:%.*]])
-; ANY-NEXT:    [[TMP1:%.*]] = fsub nnan afn float -0.000000e+00, [[SIN]]
-; ANY-NEXT:    ret float [[TMP1]]
-;
-  %neg = fsub ninf float -0.0, %x
-  %r = call afn nnan float @sinf(float %neg)
-  ret float %r
-}
-
 declare void @use(double)
 
 define double @sin_negated_arg_extra_use(double %x) {