blob: 0cd5eb5408e3ed91956f1d33195d27583f356e8b [file] [log] [blame]
Justin Lebar7d818132017-01-10 23:43:04 +00001; Check that we can enable/disable NoInfsFPMath and NoNaNsInFPMath via function
2; attributes. An attribute on one function should not magically apply to the
3; next one.
4
5; RUN: llc < %s -mtriple=powerpc64-unknown-unknown -mcpu=pwr7 -mattr=-vsx \
6; RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=SAFE
7
8; RUN: llc < %s -mtriple=powerpc64-unknown-unknown -mcpu=pwr7 -mattr=-vsx \
9; RUN: -enable-no-infs-fp-math -enable-no-nans-fp-math \
10; RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=UNSAFE
11
12; The fcmp+select in these functions should be converted to a fsel instruction
13; when both NoInfsFPMath and NoNaNsInFPMath are enabled.
14
15; CHECK-LABEL: default0:
16define double @default0(double %a, double %y, double %z) {
17entry:
18; SAFE-NOT: fsel
19; UNSAFE: fsel
20 %cmp = fcmp ult double %a, 0.000000e+00
21 %z.y = select i1 %cmp, double %z, double %y
22 ret double %z.y
23}
24
25; CHECK-LABEL: unsafe_math_off:
26define double @unsafe_math_off(double %a, double %y, double %z) #0 #2 {
27entry:
28; SAFE-NOT: fsel
29; UNSAFE-NOT: fsel
30 %cmp = fcmp ult double %a, 0.000000e+00
31 %z.y = select i1 %cmp, double %z, double %y
32 ret double %z.y
33}
34
35; CHECK-LABEL: default1:
36define double @default1(double %a, double %y, double %z) {
37; SAFE-NOT: fsel
38; UNSAFE: fsel
39 %cmp = fcmp ult double %a, 0.000000e+00
40 %z.y = select i1 %cmp, double %z, double %y
41 ret double %z.y
42}
43
44; CHECK-LABEL: unsafe_math_on:
45define double @unsafe_math_on(double %a, double %y, double %z) #1 #3 {
46entry:
47; SAFE-NOT: fsel
48; UNSAFE-NOT: fsel
49 %cmp = fcmp ult double %a, 0.000000e+00
50 %z.y = select i1 %cmp, double %z, double %y
51 ret double %z.y
52}
53
54; CHECK-LABEL: default2:
55define double @default2(double %a, double %y, double %z) {
56; SAFE-NOT: fsel
57; UNSAFE: fsel
58 %cmp = fcmp ult double %a, 0.000000e+00
59 %z.y = select i1 %cmp, double %z, double %y
60 ret double %z.y
61}
62
63attributes #0 = { "no-infs-fp-math"="false" }
64attributes #1 = { "no-nans-fp-math"="false" }
65
66attributes #2 = { "no-infs-fp-math"="false" }
67attributes #3 = { "no-infs-fp-math"="true" }