blob: 33a7ec9bfc79445215b5d2ba8c509cd3ac1409fe [file] [log] [blame]
Justin Lebar7d818132017-01-10 23:43:04 +00001; Check that we can enable/disable UnsafeFPMath via function attributes. An
2; attribute on one function should not magically apply to the next one.
3
4; RUN: llc < %s -mtriple=x86_64-unknown-unknown \
5; RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=SAFE
6
7; RUN: llc < %s -mtriple=x86_64-unknown-unknown -enable-unsafe-fp-math \
8; RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=UNSAFE
9
10; The div in these functions should be converted to a mul when unsafe-fp-math
11; is enabled.
12
13; CHECK-LABEL: unsafe_fp_math_default0:
14define double @unsafe_fp_math_default0(double %x) {
15; SAFE: divsd
16; UNSAFE: mulsd
17 %div = fdiv double %x, 2.0
18 ret double %div
19}
20
21; CHECK-LABEL: unsafe_fp_math_off:
22define double @unsafe_fp_math_off(double %x) #0 {
23; SAFE: divsd
24; UNSAFE: divsd
25 %div = fdiv double %x, 2.0
26 ret double %div
27}
28
29; CHECK-LABEL: unsafe_fp_math_default1:
30define double @unsafe_fp_math_default1(double %x) {
31; With unsafe math enabled, can change this div to a mul.
32; SAFE: divsd
33; UNSAFE: mulsd
34 %div = fdiv double %x, 2.0
35 ret double %div
36}
37
38; CHECK-LABEL: unsafe_fp_math_on:
39define double @unsafe_fp_math_on(double %x) #1 {
40; SAFE: mulsd
41; UNSAFE: mulsd
42 %div = fdiv double %x, 2.0
43 ret double %div
44}
45
46; CHECK-LABEL: unsafe_fp_math_default2:
47define double @unsafe_fp_math_default2(double %x) {
48; With unsafe math enabled, can change this div to a mul.
49; SAFE: divsd
50; UNSAFE: mulsd
51 %div = fdiv double %x, 2.0
52 ret double %div
53}
54
55attributes #0 = { "unsafe-fp-math"="false" }
56attributes #1 = { "unsafe-fp-math"="true" }