1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv32 -mattr=+d -verify-machineinstrs < %s \
; RUN: -target-abi=ilp32d | FileCheck %s --check-prefix=CHECK32D
; RUN: llc -mtriple=riscv64 -mattr=+d -verify-machineinstrs < %s \
; RUN: -target-abi=lp64d | FileCheck %s --check-prefix=CHECK64D
; RUN: llc -mtriple=riscv32 -mattr=+zdinx -verify-machineinstrs < %s \
; RUN: -target-abi=ilp32 | FileCheck --check-prefix=CHECKRV32ZDINX %s
; RUN: llc -mtriple=riscv64 -mattr=+zdinx -verify-machineinstrs < %s \
; RUN: -target-abi=lp64 | FileCheck --check-prefix=CHECKRV64ZDINX %s
define double @double_imm() nounwind {
; CHECK32D-LABEL: double_imm:
; CHECK32D: # %bb.0:
; CHECK32D-NEXT: lui a0, %hi(.LCPI0_0)
; CHECK32D-NEXT: fld fa0, %lo(.LCPI0_0)(a0)
; CHECK32D-NEXT: ret
;
; CHECK64D-LABEL: double_imm:
; CHECK64D: # %bb.0:
; CHECK64D-NEXT: lui a0, %hi(.LCPI0_0)
; CHECK64D-NEXT: fld fa0, %lo(.LCPI0_0)(a0)
; CHECK64D-NEXT: ret
;
; CHECKRV32ZDINX-LABEL: double_imm:
; CHECKRV32ZDINX: # %bb.0:
; CHECKRV32ZDINX-NEXT: lui a0, 345155
; CHECKRV32ZDINX-NEXT: addi a0, a0, -744
; CHECKRV32ZDINX-NEXT: lui a1, 262290
; CHECKRV32ZDINX-NEXT: addi a1, a1, 507
; CHECKRV32ZDINX-NEXT: ret
;
; CHECKRV64ZDINX-LABEL: double_imm:
; CHECKRV64ZDINX: # %bb.0:
; CHECKRV64ZDINX-NEXT: lui a0, %hi(.LCPI0_0)
; CHECKRV64ZDINX-NEXT: ld a0, %lo(.LCPI0_0)(a0)
; CHECKRV64ZDINX-NEXT: ret
ret double 3.1415926535897931159979634685441851615905761718750
}
define double @double_imm_op(double %a) nounwind {
; CHECK32D-LABEL: double_imm_op:
; CHECK32D: # %bb.0:
; CHECK32D-NEXT: lui a0, %hi(.LCPI1_0)
; CHECK32D-NEXT: fld fa5, %lo(.LCPI1_0)(a0)
; CHECK32D-NEXT: fadd.d fa0, fa0, fa5
; CHECK32D-NEXT: ret
;
; CHECK64D-LABEL: double_imm_op:
; CHECK64D: # %bb.0:
; CHECK64D-NEXT: lui a0, %hi(.LCPI1_0)
; CHECK64D-NEXT: fld fa5, %lo(.LCPI1_0)(a0)
; CHECK64D-NEXT: fadd.d fa0, fa0, fa5
; CHECK64D-NEXT: ret
;
; CHECKRV32ZDINX-LABEL: double_imm_op:
; CHECKRV32ZDINX: # %bb.0:
; CHECKRV32ZDINX-NEXT: addi sp, sp, -16
; CHECKRV32ZDINX-NEXT: sw a0, 8(sp)
; CHECKRV32ZDINX-NEXT: sw a1, 12(sp)
; CHECKRV32ZDINX-NEXT: lw a0, 8(sp)
; CHECKRV32ZDINX-NEXT: lw a1, 12(sp)
; CHECKRV32ZDINX-NEXT: lui a2, %hi(.LCPI1_0)
; CHECKRV32ZDINX-NEXT: lw a3, %lo(.LCPI1_0+4)(a2)
; CHECKRV32ZDINX-NEXT: lw a2, %lo(.LCPI1_0)(a2)
; CHECKRV32ZDINX-NEXT: fadd.d a0, a0, a2
; CHECKRV32ZDINX-NEXT: sw a0, 8(sp)
; CHECKRV32ZDINX-NEXT: sw a1, 12(sp)
; CHECKRV32ZDINX-NEXT: lw a0, 8(sp)
; CHECKRV32ZDINX-NEXT: lw a1, 12(sp)
; CHECKRV32ZDINX-NEXT: addi sp, sp, 16
; CHECKRV32ZDINX-NEXT: ret
;
; CHECKRV64ZDINX-LABEL: double_imm_op:
; CHECKRV64ZDINX: # %bb.0:
; CHECKRV64ZDINX-NEXT: lui a1, %hi(.LCPI1_0)
; CHECKRV64ZDINX-NEXT: ld a1, %lo(.LCPI1_0)(a1)
; CHECKRV64ZDINX-NEXT: fadd.d a0, a0, a1
; CHECKRV64ZDINX-NEXT: ret
%1 = fadd double %a, 1.0
ret double %1
}
define double @double_positive_zero(ptr %pd) nounwind {
; CHECK32D-LABEL: double_positive_zero:
; CHECK32D: # %bb.0:
; CHECK32D-NEXT: fcvt.d.w fa0, zero
; CHECK32D-NEXT: ret
;
; CHECK64D-LABEL: double_positive_zero:
; CHECK64D: # %bb.0:
; CHECK64D-NEXT: fmv.d.x fa0, zero
; CHECK64D-NEXT: ret
;
; CHECKRV32ZDINX-LABEL: double_positive_zero:
; CHECKRV32ZDINX: # %bb.0:
; CHECKRV32ZDINX-NEXT: li a0, 0
; CHECKRV32ZDINX-NEXT: li a1, 0
; CHECKRV32ZDINX-NEXT: ret
;
; CHECKRV64ZDINX-LABEL: double_positive_zero:
; CHECKRV64ZDINX: # %bb.0:
; CHECKRV64ZDINX-NEXT: li a0, 0
; CHECKRV64ZDINX-NEXT: ret
ret double 0.0
}
define double @double_negative_zero(ptr %pd) nounwind {
; CHECK32D-LABEL: double_negative_zero:
; CHECK32D: # %bb.0:
; CHECK32D-NEXT: fcvt.d.w fa5, zero
; CHECK32D-NEXT: fneg.d fa0, fa5
; CHECK32D-NEXT: ret
;
; CHECK64D-LABEL: double_negative_zero:
; CHECK64D: # %bb.0:
; CHECK64D-NEXT: fmv.d.x fa5, zero
; CHECK64D-NEXT: fneg.d fa0, fa5
; CHECK64D-NEXT: ret
;
; CHECKRV32ZDINX-LABEL: double_negative_zero:
; CHECKRV32ZDINX: # %bb.0:
; CHECKRV32ZDINX-NEXT: lui a1, 524288
; CHECKRV32ZDINX-NEXT: li a0, 0
; CHECKRV32ZDINX-NEXT: ret
;
; CHECKRV64ZDINX-LABEL: double_negative_zero:
; CHECKRV64ZDINX: # %bb.0:
; CHECKRV64ZDINX-NEXT: li a0, -1
; CHECKRV64ZDINX-NEXT: slli a0, a0, 63
; CHECKRV64ZDINX-NEXT: ret
ret double -0.0
}
define dso_local double @negzero_sel(i16 noundef %a, double noundef %d) nounwind {
; CHECK32D-LABEL: negzero_sel:
; CHECK32D: # %bb.0: # %entry
; CHECK32D-NEXT: slli a0, a0, 16
; CHECK32D-NEXT: fcvt.d.w fa5, zero
; CHECK32D-NEXT: beqz a0, .LBB4_2
; CHECK32D-NEXT: # %bb.1: # %entry
; CHECK32D-NEXT: fneg.d fa0, fa5
; CHECK32D-NEXT: .LBB4_2: # %entry
; CHECK32D-NEXT: ret
;
; CHECK64D-LABEL: negzero_sel:
; CHECK64D: # %bb.0: # %entry
; CHECK64D-NEXT: slli a0, a0, 48
; CHECK64D-NEXT: beqz a0, .LBB4_2
; CHECK64D-NEXT: # %bb.1: # %entry
; CHECK64D-NEXT: fmv.d.x fa5, zero
; CHECK64D-NEXT: fneg.d fa0, fa5
; CHECK64D-NEXT: .LBB4_2: # %entry
; CHECK64D-NEXT: ret
;
; CHECKRV32ZDINX-LABEL: negzero_sel:
; CHECKRV32ZDINX: # %bb.0: # %entry
; CHECKRV32ZDINX-NEXT: addi sp, sp, -16
; CHECKRV32ZDINX-NEXT: sw a1, 8(sp)
; CHECKRV32ZDINX-NEXT: sw a2, 12(sp)
; CHECKRV32ZDINX-NEXT: slli a2, a0, 16
; CHECKRV32ZDINX-NEXT: fcvt.d.w a0, zero
; CHECKRV32ZDINX-NEXT: beqz a2, .LBB4_2
; CHECKRV32ZDINX-NEXT: # %bb.1: # %entry
; CHECKRV32ZDINX-NEXT: fneg.d a0, a0
; CHECKRV32ZDINX-NEXT: j .LBB4_3
; CHECKRV32ZDINX-NEXT: .LBB4_2:
; CHECKRV32ZDINX-NEXT: lw a0, 8(sp)
; CHECKRV32ZDINX-NEXT: lw a1, 12(sp)
; CHECKRV32ZDINX-NEXT: .LBB4_3: # %entry
; CHECKRV32ZDINX-NEXT: sw a0, 8(sp)
; CHECKRV32ZDINX-NEXT: sw a1, 12(sp)
; CHECKRV32ZDINX-NEXT: lw a0, 8(sp)
; CHECKRV32ZDINX-NEXT: lw a1, 12(sp)
; CHECKRV32ZDINX-NEXT: addi sp, sp, 16
; CHECKRV32ZDINX-NEXT: ret
;
; CHECKRV64ZDINX-LABEL: negzero_sel:
; CHECKRV64ZDINX: # %bb.0: # %entry
; CHECKRV64ZDINX-NEXT: slli a2, a0, 48
; CHECKRV64ZDINX-NEXT: beqz a2, .LBB4_2
; CHECKRV64ZDINX-NEXT: # %bb.1: # %entry
; CHECKRV64ZDINX-NEXT: fneg.d a0, zero
; CHECKRV64ZDINX-NEXT: ret
; CHECKRV64ZDINX-NEXT: .LBB4_2:
; CHECKRV64ZDINX-NEXT: mv a0, a1
; CHECKRV64ZDINX-NEXT: ret
entry:
%tobool.not = icmp eq i16 %a, 0
%d. = select i1 %tobool.not, double %d, double -0.000000e+00
ret double %d.
}
|