llvm.org GIT mirror llvm / 6dc7763
[ConstProp] move test file from InstSimplify; NFC These are constant folding tests; there is no code directly in InstSimplify for this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@371619 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel a month ago
2 changed file(s) with 126 addition(s) and 126 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -constprop -S < %s | FileCheck %s
2
3 ; Fixes PR20832
4 ; Make sure that we correctly fold a fused multiply-add where operands
5 ; are all finite constants and addend is zero.
6
7 declare double @llvm.fma.f64(double, double, double)
8
9
10 define double @PR20832() {
11 ; CHECK-LABEL: @PR20832(
12 ; CHECK-NEXT: ret double 5.600000e+01
13 ;
14 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0.0)
15 ret double %1
16 }
17
18 ; Test builtin fma with all finite non-zero constants.
19 define double @test_all_finite() {
20 ; CHECK-LABEL: @test_all_finite(
21 ; CHECK-NEXT: ret double 6.100000e+01
22 ;
23 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 5.0)
24 ret double %1
25 }
26
27 ; Test builtin fma with a +/-NaN addend.
28 define double @test_NaN_addend() {
29 ; CHECK-LABEL: @test_NaN_addend(
30 ; CHECK-NEXT: ret double 0x7FF8000000000000
31 ;
32 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0x7FF8000000000000)
33 ret double %1
34 }
35
36 define double @test_NaN_addend_2() {
37 ; CHECK-LABEL: @test_NaN_addend_2(
38 ; CHECK-NEXT: ret double 0xFFF8000000000000
39 ;
40 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0xFFF8000000000000)
41 ret double %1
42 }
43
44 ; Test builtin fma with a +/-Inf addend.
45 define double @test_Inf_addend() {
46 ; CHECK-LABEL: @test_Inf_addend(
47 ; CHECK-NEXT: ret double 0x7FF0000000000000
48 ;
49 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0x7FF0000000000000)
50 ret double %1
51 }
52
53 define double @test_Inf_addend_2() {
54 ; CHECK-LABEL: @test_Inf_addend_2(
55 ; CHECK-NEXT: ret double 0xFFF0000000000000
56 ;
57 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0xFFF0000000000000)
58 ret double %1
59 }
60
61 ; Test builtin fma with one of the operands to the multiply being +/-NaN.
62 define double @test_NaN_1() {
63 ; CHECK-LABEL: @test_NaN_1(
64 ; CHECK-NEXT: ret double 0x7FF8000000000000
65 ;
66 %1 = call double @llvm.fma.f64(double 0x7FF8000000000000, double 8.0, double 0.0)
67 ret double %1
68 }
69
70 define double @test_NaN_2() {
71 ; CHECK-LABEL: @test_NaN_2(
72 ; CHECK-NEXT: ret double 0x7FF8000000000000
73 ;
74 %1 = call double @llvm.fma.f64(double 7.0, double 0x7FF8000000000000, double 0.0)
75 ret double %1
76 }
77
78 define double @test_NaN_3() {
79 ; CHECK-LABEL: @test_NaN_3(
80 ; CHECK-NEXT: ret double 0x7FF8000000000000
81 ;
82 %1 = call double @llvm.fma.f64(double 0xFFF8000000000000, double 8.0, double 0.0)
83 ret double %1
84 }
85
86 define double @test_NaN_4() {
87 ; CHECK-LABEL: @test_NaN_4(
88 ; CHECK-NEXT: ret double 0x7FF8000000000000
89 ;
90 %1 = call double @llvm.fma.f64(double 7.0, double 0xFFF8000000000000, double 0.0)
91 ret double %1
92 }
93
94 ; Test builtin fma with one of the operands to the multiply being +/-Inf.
95 define double @test_Inf_1() {
96 ; CHECK-LABEL: @test_Inf_1(
97 ; CHECK-NEXT: ret double 0x7FF0000000000000
98 ;
99 %1 = call double @llvm.fma.f64(double 0x7FF0000000000000, double 8.0, double 0.0)
100 ret double %1
101 }
102
103 define double @test_Inf_2() {
104 ; CHECK-LABEL: @test_Inf_2(
105 ; CHECK-NEXT: ret double 0x7FF0000000000000
106 ;
107 %1 = call double @llvm.fma.f64(double 7.0, double 0x7FF0000000000000, double 0.0)
108 ret double %1
109 }
110
111 define double @test_Inf_3() {
112 ; CHECK-LABEL: @test_Inf_3(
113 ; CHECK-NEXT: ret double 0xFFF0000000000000
114 ;
115 %1 = call double @llvm.fma.f64(double 0xFFF0000000000000, double 8.0, double 0.0)
116 ret double %1
117 }
118
119 define double @test_Inf_4() {
120 ; CHECK-LABEL: @test_Inf_4(
121 ; CHECK-NEXT: ret double 0xFFF0000000000000
122 ;
123 %1 = call double @llvm.fma.f64(double 7.0, double 0xFFF0000000000000, double 0.0)
124 ret double %1
125 }
+0
-126
test/Transforms/InstSimplify/fold-builtin-fma.ll less more
None ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -instsimplify -S < %s | FileCheck %s
2
3 ; Fixes PR20832
4 ; Make sure that we correctly fold a fused multiply-add where operands
5 ; are all finite constants and addend is zero.
6
7 declare double @llvm.fma.f64(double, double, double)
8
9
10 define double @PR20832() {
11 ; CHECK-LABEL: @PR20832(
12 ; CHECK-NEXT: ret double 5.600000e+01
13 ;
14 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0.0)
15 ret double %1
16 }
17
18 ; Test builtin fma with all finite non-zero constants.
19 define double @test_all_finite() {
20 ; CHECK-LABEL: @test_all_finite(
21 ; CHECK-NEXT: ret double 6.100000e+01
22 ;
23 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 5.0)
24 ret double %1
25 }
26
27 ; Test builtin fma with a +/-NaN addend.
28 define double @test_NaN_addend() {
29 ; CHECK-LABEL: @test_NaN_addend(
30 ; CHECK-NEXT: ret double 0x7FF8000000000000
31 ;
32 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0x7FF8000000000000)
33 ret double %1
34 }
35
36 define double @test_NaN_addend_2() {
37 ; CHECK-LABEL: @test_NaN_addend_2(
38 ; CHECK-NEXT: ret double 0xFFF8000000000000
39 ;
40 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0xFFF8000000000000)
41 ret double %1
42 }
43
44 ; Test builtin fma with a +/-Inf addend.
45 define double @test_Inf_addend() {
46 ; CHECK-LABEL: @test_Inf_addend(
47 ; CHECK-NEXT: ret double 0x7FF0000000000000
48 ;
49 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0x7FF0000000000000)
50 ret double %1
51 }
52
53 define double @test_Inf_addend_2() {
54 ; CHECK-LABEL: @test_Inf_addend_2(
55 ; CHECK-NEXT: ret double 0xFFF0000000000000
56 ;
57 %1 = call double @llvm.fma.f64(double 7.0, double 8.0, double 0xFFF0000000000000)
58 ret double %1
59 }
60
61 ; Test builtin fma with one of the operands to the multiply being +/-NaN.
62 define double @test_NaN_1() {
63 ; CHECK-LABEL: @test_NaN_1(
64 ; CHECK-NEXT: ret double 0x7FF8000000000000
65 ;
66 %1 = call double @llvm.fma.f64(double 0x7FF8000000000000, double 8.0, double 0.0)
67 ret double %1
68 }
69
70 define double @test_NaN_2() {
71 ; CHECK-LABEL: @test_NaN_2(
72 ; CHECK-NEXT: ret double 0x7FF8000000000000
73 ;
74 %1 = call double @llvm.fma.f64(double 7.0, double 0x7FF8000000000000, double 0.0)
75 ret double %1
76 }
77
78 define double @test_NaN_3() {
79 ; CHECK-LABEL: @test_NaN_3(
80 ; CHECK-NEXT: ret double 0x7FF8000000000000
81 ;
82 %1 = call double @llvm.fma.f64(double 0xFFF8000000000000, double 8.0, double 0.0)
83 ret double %1
84 }
85
86 define double @test_NaN_4() {
87 ; CHECK-LABEL: @test_NaN_4(
88 ; CHECK-NEXT: ret double 0x7FF8000000000000
89 ;
90 %1 = call double @llvm.fma.f64(double 7.0, double 0xFFF8000000000000, double 0.0)
91 ret double %1
92 }
93
94 ; Test builtin fma with one of the operands to the multiply being +/-Inf.
95 define double @test_Inf_1() {
96 ; CHECK-LABEL: @test_Inf_1(
97 ; CHECK-NEXT: ret double 0x7FF0000000000000
98 ;
99 %1 = call double @llvm.fma.f64(double 0x7FF0000000000000, double 8.0, double 0.0)
100 ret double %1
101 }
102
103 define double @test_Inf_2() {
104 ; CHECK-LABEL: @test_Inf_2(
105 ; CHECK-NEXT: ret double 0x7FF0000000000000
106 ;
107 %1 = call double @llvm.fma.f64(double 7.0, double 0x7FF0000000000000, double 0.0)
108 ret double %1
109 }
110
111 define double @test_Inf_3() {
112 ; CHECK-LABEL: @test_Inf_3(
113 ; CHECK-NEXT: ret double 0xFFF0000000000000
114 ;
115 %1 = call double @llvm.fma.f64(double 0xFFF0000000000000, double 8.0, double 0.0)
116 ret double %1
117 }
118
119 define double @test_Inf_4() {
120 ; CHECK-LABEL: @test_Inf_4(
121 ; CHECK-NEXT: ret double 0xFFF0000000000000
122 ;
123 %1 = call double @llvm.fma.f64(double 7.0, double 0xFFF0000000000000, double 0.0)
124 ret double %1
125 }