Skip to content

Commit f43d6a4

Browse files
committed
test cases: use alloca type when applicable
1 parent 3d61370 commit f43d6a4

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

llvm/test/Transforms/InstCombine/memcpy_alloca.ll

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,38 @@ define void @test6(ptr %dest) {
7171
ret void
7272
}
7373

74+
; Infer the type of the generated load/store when possible from an alloca
75+
76+
define void @test7(ptr %src, ptr %dest) {
77+
; CHECK-LABEL: @test7(
78+
; CHECK-NEXT: %[[UNPACK0:.*]] = load i32, ptr %src, align 1
79+
; CHECK-NEXT: %[[SRC_GEP:.*]] = getelementptr inbounds nuw i8, ptr %src, i64 4
80+
; CHECK-NEXT: %[[UNPACK1:.*]] = load i32, ptr %[[SRC_GEP]], align 1
81+
; CHECK-NEXT: store i32 %[[UNPACK0]], ptr %dest, align 1
82+
; CHECK-NEXT: %[[DEST_GEP:.*]] = getelementptr inbounds nuw i8, ptr %dest, i64 4
83+
; CHECK-NEXT: store i32 %[[UNPACK1]], ptr %[[DEST_GEP]], align 1
84+
; CHECK-NEXT: ret void
85+
;
86+
%temp = alloca [2 x i32], align 4
87+
call void @llvm.memcpy.p0.p0.i32(ptr %temp, ptr %src, i32 8, i1 false)
88+
call void @llvm.memcpy.p0.p0.i32(ptr %dest, ptr %temp, i32 8, i1 false)
89+
90+
ret void
91+
}
92+
93+
; Ensure we don't use alloca type if only paritally copying
94+
95+
define void @test8(ptr %src, ptr %dest) {
96+
; CHECK-LABEL: @test8(
97+
; CHECK-NEXT: %[[LI:.*]] = load i32, ptr %src, align 1
98+
; CHECK-NEXT: store i32 %[[LI]], ptr %dest, align 1
99+
; CHECK-NEXT: ret void
100+
;
101+
%temp = alloca [2 x i32], align 4
102+
call void @llvm.memcpy.p0.p0.i32(ptr %temp, ptr %src, i32 4, i1 false)
103+
call void @llvm.memcpy.p0.p0.i32(ptr %dest, ptr %temp, i32 4, i1 false)
104+
105+
ret void
106+
}
107+
74108
declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1)

0 commit comments

Comments
 (0)