File: add_shl_constant.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (256 lines) | stat: -rw-r--r-- 7,700 bytes parent folder | download | duplicates (2)
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc -mtriple=riscv32  < %s | FileCheck -check-prefixes=RV32,NO-ZBA %s
; RUN: llc -mtriple=riscv32 -mattr=+zba  < %s | FileCheck -check-prefixes=RV32,ZBA %s

define i32 @add_shl_oneUse(i32 %x, i32 %y) nounwind {
; NO-ZBA-LABEL: add_shl_oneUse:
; NO-ZBA:       # %bb.0:
; NO-ZBA-NEXT:    slli a0, a0, 3
; NO-ZBA-NEXT:    add a0, a0, a1
; NO-ZBA-NEXT:    addi a0, a0, 984
; NO-ZBA-NEXT:    ret
;
; ZBA-LABEL: add_shl_oneUse:
; ZBA:       # %bb.0:
; ZBA-NEXT:    addi a0, a0, 123
; ZBA-NEXT:    sh3add a0, a0, a1
; ZBA-NEXT:    ret
  %add.0 = add i32 %x, 123
  %shl = shl i32 %add.0, 3
  %add.1 = add i32 %shl, %y
  ret i32 %add.1
}

define void @add_shl_moreOneUse_inStore(ptr %array1, i32 %a, i32 %b)  {
; NO-ZBA-LABEL: add_shl_moreOneUse_inStore:
; NO-ZBA:       # %bb.0: # %entry
; NO-ZBA-NEXT:    addi a3, a1, 5
; NO-ZBA-NEXT:    slli a1, a1, 2
; NO-ZBA-NEXT:    add a0, a0, a1
; NO-ZBA-NEXT:    sw a2, 20(a0)
; NO-ZBA-NEXT:    sw a2, 24(a0)
; NO-ZBA-NEXT:    sw a3, 140(a0)
; NO-ZBA-NEXT:    ret
;
; ZBA-LABEL: add_shl_moreOneUse_inStore:
; ZBA:       # %bb.0: # %entry
; ZBA-NEXT:    addi a3, a1, 5
; ZBA-NEXT:    sh2add a0, a1, a0
; ZBA-NEXT:    sw a2, 20(a0)
; ZBA-NEXT:    sw a2, 24(a0)
; ZBA-NEXT:    sw a3, 140(a0)
; ZBA-NEXT:    ret
entry:
  %add = add nsw i32 %a, 5
  %arrayidx = getelementptr inbounds i32, ptr %array1, i32 %add
  store i32 %b, ptr %arrayidx
  %0 = getelementptr i32, ptr %array1, i32 %a
  %arrayidx3 = getelementptr i8, ptr %0, i32 24
  store i32 %b, ptr %arrayidx3
  %arrayidx5 = getelementptr i8, ptr %0, i32 140
  store i32 %add, ptr %arrayidx5
  ret void
}

define void @add_shl_moreOneUse_inStore_addexceedsign12(ptr %array1, i32 %a, i32 %b)  {
; NO-ZBA-LABEL: add_shl_moreOneUse_inStore_addexceedsign12:
; NO-ZBA:       # %bb.0: # %entry
; NO-ZBA-NEXT:    addi a3, a1, 2047
; NO-ZBA-NEXT:    lui a4, 2
; NO-ZBA-NEXT:    slli a1, a1, 2
; NO-ZBA-NEXT:    addi a3, a3, 1
; NO-ZBA-NEXT:    add a0, a0, a1
; NO-ZBA-NEXT:    add a0, a0, a4
; NO-ZBA-NEXT:    sw a2, 0(a0)
; NO-ZBA-NEXT:    sw a3, 4(a0)
; NO-ZBA-NEXT:    sw a2, 120(a0)
; NO-ZBA-NEXT:    ret
;
; ZBA-LABEL: add_shl_moreOneUse_inStore_addexceedsign12:
; ZBA:       # %bb.0: # %entry
; ZBA-NEXT:    addi a3, a1, 2047
; ZBA-NEXT:    lui a4, 2
; ZBA-NEXT:    sh2add a0, a1, a0
; ZBA-NEXT:    addi a3, a3, 1
; ZBA-NEXT:    add a0, a0, a4
; ZBA-NEXT:    sw a2, 0(a0)
; ZBA-NEXT:    sw a3, 4(a0)
; ZBA-NEXT:    sw a2, 120(a0)
; ZBA-NEXT:    ret
entry:
  %add = add nsw i32 %a, 2048
  %arrayidx = getelementptr inbounds i32, ptr %array1, i32 %add
  store i32 %b, ptr %arrayidx
  %0 = getelementptr i32, ptr %array1, i32 %a
  %arrayidx2 = getelementptr i8, ptr %0, i32 8196
  store i32 %add, ptr %arrayidx2
  %arrayidx4 = getelementptr i8, ptr %0, i32 8312
  store i32 %b, ptr %arrayidx4
  ret void
}

define void @add_shl_moreOneUse_inSelect(ptr %array1, i32 %a, i32 %b, i32 %x) {
; NO-ZBA-LABEL: add_shl_moreOneUse_inSelect:
; NO-ZBA:       # %bb.0: # %entry
; NO-ZBA-NEXT:    addi a4, a1, 5
; NO-ZBA-NEXT:    mv a5, a4
; NO-ZBA-NEXT:    bgtz a3, .LBB3_2
; NO-ZBA-NEXT:  # %bb.1: # %entry
; NO-ZBA-NEXT:    mv a5, a2
; NO-ZBA-NEXT:  .LBB3_2: # %entry
; NO-ZBA-NEXT:    slli a1, a1, 2
; NO-ZBA-NEXT:    add a0, a0, a1
; NO-ZBA-NEXT:    sw a5, 20(a0)
; NO-ZBA-NEXT:    sw a5, 24(a0)
; NO-ZBA-NEXT:    sw a4, 140(a0)
; NO-ZBA-NEXT:    ret
;
; ZBA-LABEL: add_shl_moreOneUse_inSelect:
; ZBA:       # %bb.0: # %entry
; ZBA-NEXT:    addi a4, a1, 5
; ZBA-NEXT:    mv a5, a4
; ZBA-NEXT:    bgtz a3, .LBB3_2
; ZBA-NEXT:  # %bb.1: # %entry
; ZBA-NEXT:    mv a5, a2
; ZBA-NEXT:  .LBB3_2: # %entry
; ZBA-NEXT:    sh2add a0, a1, a0
; ZBA-NEXT:    sw a5, 20(a0)
; ZBA-NEXT:    sw a5, 24(a0)
; ZBA-NEXT:    sw a4, 140(a0)
; ZBA-NEXT:    ret
entry:
  %add = add nsw i32 %a, 5
  %cmp = icmp sgt i32 %x, 0
  %cond = select i1 %cmp, i32 %add, i32 %b
  %arrayidx = getelementptr inbounds i32, ptr %array1, i32 %add
  store i32 %cond, ptr %arrayidx
  %0 = getelementptr i32, ptr %array1, i32 %a
  %arrayidx2 = getelementptr i32, ptr %0, i32 6
  store i32 %cond, ptr %arrayidx2
  %arrayidx4 = getelementptr i32, ptr %0, i32 35
  store i32 %add, ptr %arrayidx4
  ret void
}

define void @add_shl_moreOneUse_inSelect_addexceedsign12(ptr %array1, i32 %a, i32 %b, i32 %x) {
; NO-ZBA-LABEL: add_shl_moreOneUse_inSelect_addexceedsign12:
; NO-ZBA:       # %bb.0: # %entry
; NO-ZBA-NEXT:    addi a4, a1, 2047
; NO-ZBA-NEXT:    addi a4, a4, 1
; NO-ZBA-NEXT:    mv a5, a4
; NO-ZBA-NEXT:    bgtz a3, .LBB4_2
; NO-ZBA-NEXT:  # %bb.1: # %entry
; NO-ZBA-NEXT:    mv a5, a2
; NO-ZBA-NEXT:  .LBB4_2: # %entry
; NO-ZBA-NEXT:    lui a2, 2
; NO-ZBA-NEXT:    slli a1, a1, 2
; NO-ZBA-NEXT:    add a0, a0, a1
; NO-ZBA-NEXT:    add a0, a0, a2
; NO-ZBA-NEXT:    sw a5, 0(a0)
; NO-ZBA-NEXT:    sw a5, 4(a0)
; NO-ZBA-NEXT:    sw a4, 120(a0)
; NO-ZBA-NEXT:    ret
;
; ZBA-LABEL: add_shl_moreOneUse_inSelect_addexceedsign12:
; ZBA:       # %bb.0: # %entry
; ZBA-NEXT:    addi a4, a1, 2047
; ZBA-NEXT:    addi a4, a4, 1
; ZBA-NEXT:    mv a5, a4
; ZBA-NEXT:    bgtz a3, .LBB4_2
; ZBA-NEXT:  # %bb.1: # %entry
; ZBA-NEXT:    mv a5, a2
; ZBA-NEXT:  .LBB4_2: # %entry
; ZBA-NEXT:    lui a2, 2
; ZBA-NEXT:    sh2add a0, a1, a0
; ZBA-NEXT:    add a0, a0, a2
; ZBA-NEXT:    sw a5, 0(a0)
; ZBA-NEXT:    sw a5, 4(a0)
; ZBA-NEXT:    sw a4, 120(a0)
; ZBA-NEXT:    ret
entry:
  %add = add nsw i32 %a, 2048
  %cmp = icmp sgt i32 %x, 0
  %spec.select = select i1 %cmp, i32 %add, i32 %b
  %0 = getelementptr inbounds i32, ptr %array1, i32 %add
  store i32 %spec.select, ptr %0, align 4
  %1 = getelementptr i32, ptr %array1, i32 %a
  %arrayidx4 = getelementptr i8, ptr %1, i32 8196
  store i32 %spec.select, ptr %arrayidx4
  %arrayidx6 = getelementptr i8, ptr %1, i32 8312
  store i32 %add, ptr %arrayidx6
  ret void
}

define i32 @add_shl_moreOneUse_sh1add(i32 %x) {
; NO-ZBA-LABEL: add_shl_moreOneUse_sh1add:
; NO-ZBA:       # %bb.0:
; NO-ZBA-NEXT:    ori a1, a0, 1
; NO-ZBA-NEXT:    slli a0, a0, 1
; NO-ZBA-NEXT:    ori a0, a0, 2
; NO-ZBA-NEXT:    add a0, a0, a1
; NO-ZBA-NEXT:    ret
;
; ZBA-LABEL: add_shl_moreOneUse_sh1add:
; ZBA:       # %bb.0:
; ZBA-NEXT:    ori a0, a0, 1
; ZBA-NEXT:    sh1add a0, a0, a0
; ZBA-NEXT:    ret
  %or = or i32 %x, 1
  %mul = shl i32 %or, 1
  %add = add i32 %mul, %or
  ret i32 %add
}

define i32 @add_shl_moreOneUse_sh2add(i32 %x) {
; NO-ZBA-LABEL: add_shl_moreOneUse_sh2add:
; NO-ZBA:       # %bb.0:
; NO-ZBA-NEXT:    ori a1, a0, 1
; NO-ZBA-NEXT:    slli a0, a0, 2
; NO-ZBA-NEXT:    ori a0, a0, 4
; NO-ZBA-NEXT:    add a0, a0, a1
; NO-ZBA-NEXT:    ret
;
; ZBA-LABEL: add_shl_moreOneUse_sh2add:
; ZBA:       # %bb.0:
; ZBA-NEXT:    ori a0, a0, 1
; ZBA-NEXT:    sh2add a0, a0, a0
; ZBA-NEXT:    ret
  %or = or i32 %x, 1
  %mul = shl i32 %or, 2
  %add = add i32 %mul, %or
  ret i32 %add
}

define i32 @add_shl_moreOneUse_sh3add(i32 %x) {
; NO-ZBA-LABEL: add_shl_moreOneUse_sh3add:
; NO-ZBA:       # %bb.0:
; NO-ZBA-NEXT:    ori a1, a0, 1
; NO-ZBA-NEXT:    slli a0, a0, 3
; NO-ZBA-NEXT:    ori a0, a0, 8
; NO-ZBA-NEXT:    add a0, a0, a1
; NO-ZBA-NEXT:    ret
;
; ZBA-LABEL: add_shl_moreOneUse_sh3add:
; ZBA:       # %bb.0:
; ZBA-NEXT:    ori a0, a0, 1
; ZBA-NEXT:    sh3add a0, a0, a0
; ZBA-NEXT:    ret
  %or = or i32 %x, 1
  %mul = shl i32 %or, 3
  %add = add i32 %mul, %or
  ret i32 %add
}

define i32 @add_shl_moreOneUse_sh4add(i32 %x) {
; RV32-LABEL: add_shl_moreOneUse_sh4add:
; RV32:       # %bb.0:
; RV32-NEXT:    ori a1, a0, 1
; RV32-NEXT:    slli a0, a0, 4
; RV32-NEXT:    ori a0, a0, 16
; RV32-NEXT:    add a0, a0, a1
; RV32-NEXT:    ret
  %or = or i32 %x, 1
  %mul = shl i32 %or, 4
  %add = add i32 %mul, %or
  ret i32 %add
}