• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s
3
4; https://bugs.llvm.org/show_bug.cgi?id=41668
5
6define double @constant_fold_fdiv_by_zero(double* %p) {
7; CHECK-LABEL: constant_fold_fdiv_by_zero:
8; CHECK:       // %bb.0:
9; CHECK-NEXT:    mov x8, #9218868437227405312
10; CHECK-NEXT:    fmov d0, x8
11; CHECK-NEXT:    ret
12  %r = fdiv double 4.940660e-324, 0.0
13  ret double %r
14}
15
16; frem by 0.0 --> NaN
17
18define double @constant_fold_frem_by_zero(double* %p) {
19; CHECK-LABEL: constant_fold_frem_by_zero:
20; CHECK:       // %bb.0:
21; CHECK-NEXT:    mov x8, #9221120237041090560
22; CHECK-NEXT:    fmov d0, x8
23; CHECK-NEXT:    ret
24  %r = frem double 4.940660e-324, 0.0
25  ret double %r
26}
27
28; Inf * 0.0 --> NaN
29
30define double @constant_fold_fmul_nan(double* %p) {
31; CHECK-LABEL: constant_fold_fmul_nan:
32; CHECK:       // %bb.0:
33; CHECK-NEXT:    mov x8, #9221120237041090560
34; CHECK-NEXT:    fmov d0, x8
35; CHECK-NEXT:    ret
36  %r = fmul double 0x7ff0000000000000, 0.0
37  ret double %r
38}
39
40; Inf + -Inf --> NaN
41
42define double @constant_fold_fadd_nan(double* %p) {
43; CHECK-LABEL: constant_fold_fadd_nan:
44; CHECK:       // %bb.0:
45; CHECK-NEXT:    mov x8, #9221120237041090560
46; CHECK-NEXT:    fmov d0, x8
47; CHECK-NEXT:    ret
48  %r = fadd double 0x7ff0000000000000, 0xfff0000000000000
49  ret double %r
50}
51
52; Inf - Inf --> NaN
53
54define double @constant_fold_fsub_nan(double* %p) {
55; CHECK-LABEL: constant_fold_fsub_nan:
56; CHECK:       // %bb.0:
57; CHECK-NEXT:    mov x8, #9221120237041090560
58; CHECK-NEXT:    fmov d0, x8
59; CHECK-NEXT:    ret
60  %r = fsub double 0x7ff0000000000000, 0x7ff0000000000000
61  ret double %r
62}
63
64; Inf * 0.0 + ? --> NaN
65
66define double @constant_fold_fma_nan(double* %p) {
67; CHECK-LABEL: constant_fold_fma_nan:
68; CHECK:       // %bb.0:
69; CHECK-NEXT:    mov x8, #9221120237041090560
70; CHECK-NEXT:    fmov d0, x8
71; CHECK-NEXT:    ret
72  %r =  call double @llvm.fma.f64(double 0x7ff0000000000000, double 0.0, double 42.0)
73  ret double %r
74}
75
76define double @fdiv_nnan_nan_op0(double %x) {
77; CHECK-LABEL: fdiv_nnan_nan_op0:
78; CHECK:       // %bb.0:
79; CHECK-NEXT:    ret
80  %r = fdiv nnan double 0xfff8000000000000, %x
81  ret double %r
82}
83
84define double @fmul_nnan_nan_op1(double %x) {
85; CHECK-LABEL: fmul_nnan_nan_op1:
86; CHECK:       // %bb.0:
87; CHECK-NEXT:    ret
88  %r = fmul nnan double %x, 0x7ff8000000000000
89  ret double %r
90}
91
92; Negative test - nan is ok.
93; TODO: Should simplify to nan.
94
95define double @fdiv_ninf_nan_op0(double %x) {
96; CHECK-LABEL: fdiv_ninf_nan_op0:
97; CHECK:       // %bb.0:
98; CHECK-NEXT:    mov x8, #-2251799813685248
99; CHECK-NEXT:    fmov d1, x8
100; CHECK-NEXT:    fdiv d0, d1, d0
101; CHECK-NEXT:    ret
102  %r = fdiv ninf double 0xfff8000000000000, %x
103  ret double %r
104}
105
106; Negative test - nan is ok.
107; TODO: Should simplify to nan.
108
109define double @fadd_ninf_nan_op1(double %x) {
110; CHECK-LABEL: fadd_ninf_nan_op1:
111; CHECK:       // %bb.0:
112; CHECK-NEXT:    mov x8, #9221120237041090560
113; CHECK-NEXT:    fmov d1, x8
114; CHECK-NEXT:    fadd d0, d0, d1
115; CHECK-NEXT:    ret
116  %r = fadd ninf double %x, 0x7ff8000000000000
117  ret double %r
118}
119
120define double @fdiv_ninf_inf_op0(double %x) {
121; CHECK-LABEL: fdiv_ninf_inf_op0:
122; CHECK:       // %bb.0:
123; CHECK-NEXT:    ret
124  %r = fdiv ninf double 0x7ff0000000000000, %x
125  ret double %r
126}
127
128define double @fadd_ninf_inf_op1(double %x) {
129; CHECK-LABEL: fadd_ninf_inf_op1:
130; CHECK:       // %bb.0:
131; CHECK-NEXT:    ret
132  %r = fadd ninf double %x, 0xfff0000000000000
133  ret double %r
134}
135
136; Negative test - inf is ok.
137; TODO: Should simplify to inf.
138
139define double @fsub_nnan_inf_op0(double %x) {
140; CHECK-LABEL: fsub_nnan_inf_op0:
141; CHECK:       // %bb.0:
142; CHECK-NEXT:    mov x8, #9218868437227405312
143; CHECK-NEXT:    fmov d1, x8
144; CHECK-NEXT:    fsub d0, d1, d0
145; CHECK-NEXT:    ret
146  %r = fsub nnan double 0x7ff0000000000000, %x
147  ret double %r
148}
149
150; Negative test - inf is ok.
151; TODO: Should simplify to -inf.
152
153define double @fmul_nnan_inf_op1(double %x) {
154; CHECK-LABEL: fmul_nnan_inf_op1:
155; CHECK:       // %bb.0:
156; CHECK-NEXT:    mov x8, #-4503599627370496
157; CHECK-NEXT:    fmov d1, x8
158; CHECK-NEXT:    fmul d0, d0, d1
159; CHECK-NEXT:    ret
160  %r = fmul nnan double %x, 0xfff0000000000000
161  ret double %r
162}
163
164define double @fdiv_nnan_undef_op0(double %x) {
165; CHECK-LABEL: fdiv_nnan_undef_op0:
166; CHECK:       // %bb.0:
167; CHECK-NEXT:    ret
168  %r = fdiv nnan double undef, %x
169  ret double %r
170}
171
172define double @fdiv_nnan_undef_op1(double %x) {
173; CHECK-LABEL: fdiv_nnan_undef_op1:
174; CHECK:       // %bb.0:
175; CHECK-NEXT:    ret
176  %r = fdiv nnan double %x, undef
177  ret double %r
178}
179
180define double @fdiv_ninf_undef_op0(double %x) {
181; CHECK-LABEL: fdiv_ninf_undef_op0:
182; CHECK:       // %bb.0:
183; CHECK-NEXT:    ret
184  %r = fdiv ninf double undef, %x
185  ret double %r
186}
187
188define double @fdiv_ninf_undef_op1(double %x) {
189; CHECK-LABEL: fdiv_ninf_undef_op1:
190; CHECK:       // %bb.0:
191; CHECK-NEXT:    ret
192  %r = fdiv ninf double %x, undef
193  ret double %r
194}
195
196declare double @llvm.fma.f64(double, double, double)
197