mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
e3fb38059f
Summary: Previously if you had * a function with the fast-math-enabled attr, followed by * a function without the fast-math attr, the second function would inherit the first function's fast-math-ness. This means that mixing fast-math and non-fast-math functions in a module was completely broken unless you explicitly annotated every non-fast-math function with "unsafe-fp-math"="false". This appears to have been broken since r176986 (March 2013), when the resetTargetOptions function was introduced. This patch tests the correct behavior as best we can. I don't think I can test FPDenormalMode and NoTrappingFPMath, because they aren't used in any backends during function lowering. Surprisingly, I also can't find any uses at all of LessPreciseFPMAD affecting generated code. The NVPTX/fast-math.ll test changes are an expected result of fixing this bug. When FMA is disabled, we emit add as "add.rn.f32", which prevents fma combining. Before this patch, fast-math was enabled in all functions following the one which explicitly enabled it on itself, so we were emitting plain "add.f32" where we should have generated "add.rn.f32". Reviewers: mkuper Subscribers: hfinkel, majnemer, jholewinski, nemanjai, llvm-commits Differential Revision: https://reviews.llvm.org/D28507 llvm-svn: 291618
57 lines
1.6 KiB
LLVM
57 lines
1.6 KiB
LLVM
; Check that we can enable/disable UnsafeFPMath via function attributes. An
|
|
; attribute on one function should not magically apply to the next one.
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown \
|
|
; RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=SAFE
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -enable-unsafe-fp-math \
|
|
; RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=UNSAFE
|
|
|
|
; The div in these functions should be converted to a mul when unsafe-fp-math
|
|
; is enabled.
|
|
|
|
; CHECK-LABEL: unsafe_fp_math_default0:
|
|
define double @unsafe_fp_math_default0(double %x) {
|
|
; SAFE: divsd
|
|
; UNSAFE: mulsd
|
|
%div = fdiv double %x, 2.0
|
|
ret double %div
|
|
}
|
|
|
|
; CHECK-LABEL: unsafe_fp_math_off:
|
|
define double @unsafe_fp_math_off(double %x) #0 {
|
|
; SAFE: divsd
|
|
; UNSAFE: divsd
|
|
%div = fdiv double %x, 2.0
|
|
ret double %div
|
|
}
|
|
|
|
; CHECK-LABEL: unsafe_fp_math_default1:
|
|
define double @unsafe_fp_math_default1(double %x) {
|
|
; With unsafe math enabled, can change this div to a mul.
|
|
; SAFE: divsd
|
|
; UNSAFE: mulsd
|
|
%div = fdiv double %x, 2.0
|
|
ret double %div
|
|
}
|
|
|
|
; CHECK-LABEL: unsafe_fp_math_on:
|
|
define double @unsafe_fp_math_on(double %x) #1 {
|
|
; SAFE: mulsd
|
|
; UNSAFE: mulsd
|
|
%div = fdiv double %x, 2.0
|
|
ret double %div
|
|
}
|
|
|
|
; CHECK-LABEL: unsafe_fp_math_default2:
|
|
define double @unsafe_fp_math_default2(double %x) {
|
|
; With unsafe math enabled, can change this div to a mul.
|
|
; SAFE: divsd
|
|
; UNSAFE: mulsd
|
|
%div = fdiv double %x, 2.0
|
|
ret double %div
|
|
}
|
|
|
|
attributes #0 = { "unsafe-fp-math"="false" }
|
|
attributes #1 = { "unsafe-fp-math"="true" }
|