Skip to content

Commit 83d8478

Browse files
committed
address comments
1 parent 65dad0e commit 83d8478

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

llvm/test/Transforms/SROA/select-gep.ll

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,29 @@ define i64 @test_select_like_zext_idx_mem2reg(i1 %c) {
219219
ret i64 %res
220220
}
221221

222+
; Test gep with a zext index that is not equivalent to a select. No unfolding
223+
; or promotion should take place.
224+
define i64 @test_zext_unlike_select_idx_mem2reg(i8 %c) {
225+
; CHECK-LABEL: @test_zext_unlike_select_idx_mem2reg(
226+
; CHECK-NEXT: [[ALLOCA:%.*]] = alloca [2 x i64], align 8
227+
; CHECK-NEXT: store i64 1, ptr [[ALLOCA]], align 4
228+
; CHECK-NEXT: [[GEP1:%.*]] = getelementptr inbounds i64, ptr [[ALLOCA]], i64 1
229+
; CHECK-NEXT: store i64 2, ptr [[GEP1]], align 4
230+
; CHECK-NEXT: [[IDX:%.*]] = zext i8 [[C:%.*]] to i64
231+
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr inbounds i64, ptr [[ALLOCA]], i64 [[IDX]]
232+
; CHECK-NEXT: [[RES:%.*]] = load i64, ptr [[GEP2]], align 4
233+
; CHECK-NEXT: ret i64 [[RES]]
234+
;
235+
%alloca = alloca [2 x i64], align 8
236+
store i64 1, ptr %alloca
237+
%gep1 = getelementptr inbounds i64, ptr %alloca, i64 1
238+
store i64 2, ptr %gep1
239+
%idx = zext i8 %c to i64
240+
%gep2 = getelementptr inbounds i64, ptr %alloca, i64 %idx
241+
%res = load i64, ptr %gep2
242+
ret i64 %res
243+
}
244+
222245
; Test gep of index select unfolding on an alloca that escaped, and as such
223246
; is not splittable or promotable.
224247
; FIXME: Ideally, no transform would take place in this case.

0 commit comments

Comments
 (0)