[SimplifyLibCalls] don't drop fast-math-flags on trig reflection folds

llvm-svn: 339608
This commit is contained in:
Sanjay Patel 2018-08-13 20:14:27 +00:00
parent 753bc5496b
commit 981f50919e
2 changed files with 15 additions and 2 deletions

View File

@ -1124,7 +1124,9 @@ Value *LibCallSimplifier::optimizeCAbs(CallInst *CI, IRBuilder<> &B) {
static Value *optimizeTrigReflections(CallInst *Call, LibFunc Func,
IRBuilder<> &B) {
// FIXME: This drops FMF.
IRBuilder<>::FastMathFlagGuard Guard(B);
B.setFastMathFlags(Call->getFastMathFlags());
// TODO: Add tan() and other calls.
// TODO: Can this be shared to also handle LLVM intrinsics?
Value *X;

View 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 float @cosf(float [[X:%.*]])
; ANY-NEXT: [[COS:%.*]] = call reassoc nnan float @cosf(float [[X:%.*]])
; ANY-NEXT: ret float [[COS]]
;
%neg = fsub float -0.0, %x
@ -72,6 +72,17 @@ 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) {