Skip to content

Commit 5e04c39

Browse files
Simplified test
1 parent 4c49512 commit 5e04c39

File tree

1 file changed

+31
-42
lines changed

1 file changed

+31
-42
lines changed

llvm/test/Transforms/MemCpyOpt/memcpy-tbaa.ll

Lines changed: 31 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,58 @@
22
; The aim of this test is to check if MemCpyOpt pass merges alias tags
33
; after memcpy optimization
44

5+
; High level overview of this test
6+
; Input:
7+
; function test() {
8+
; //declaration of local arrays a and b
9+
; //initialization of array b in init_loop
10+
; //initialization of array a -> copy of array b
11+
; //use array a in loop
12+
; }
13+
;
14+
; Expected output after optimization:
15+
; function test() {
16+
; //declaration of local array b
17+
; //initialization of array b in init_loop
18+
; //use array b in loop
19+
; }
20+
521
; ModuleID = 'FIRModule'
622
source_filename = "FIRModule"
723
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
824
target triple = "x86_64-unknown-linux-gnu"
925

10-
@data_arr = internal unnamed_addr constant [31 x float] [float 0x3E68DA0CA0000000, float 0x3E692863A0000000, float 0x3E6AEF5000000000, float 0x3E6E2272C0000000, float 0x3E7271B720000000, float 0x3E777DA440000000, float 0x3E7E8C46C0000000, float 0x3E8458EFC0000000, float 0x3E8D0123C0000000, float 0x3E95E78260000000, float 0x3EA0AB7AC0000000, float 0x3EA89F4B40000000, float 0x3EB10FFB60000000, float 0x3EB5F1D140000000, float 0x3EBB435260000000, float 0x3EC0DE9700000000, float 0x3EC51B11A0000000, float 0x3ECA419FC0000000, float 0x3ED01B2B20000000, float 0x3ED3B9CEC0000000, float 0x3ED7028C40000000, float 0x3EDA60C320000000, float 0x3EDD54AD40000000, float 0x3EDF6E9F00000000, float 0x3EE130BB20000000, float 0x3EE4332400000000, float 0x3EE7575F80000000, float 0x3EE8088A60000000, float 0x3EE3B0AE60000000, float 0x3ED9BB6800000000, float 0x3ED9BB6800000000]
11-
1226
; CHECK-LABEL: @test(
1327
; CHECK: [[ARR_UNDER_TEST:%.*]] = alloca [31 x float], align 4
14-
; CHECK: store float 0x3E6AA51880000000, ptr [[ARR_UNDER_TEST]], align 4, !tbaa [[ARR_TAG:!.[0-9]+]]
1528
; CHECK-LABEL: init_loop:
16-
; CHECK: store float [[TMP0:%.*]], ptr [[TMP1:%.*]], align 4, !tbaa [[ARR_TAG]]
29+
; CHECK: [[TMP0:%.*]] = getelementptr float, ptr [[ARR_UNDER_TEST]],
30+
; CHECK: store float 0x3E6AA51880000000, ptr [[TMP0]], align 4, !tbaa [[ARR_TAG:![0-9]+]]
1731
; CHECK-LABEL: loop:
18-
; CHECK: [[TMP2:%.*]] = getelementptr float, ptr [[ARR_UNDER_TEST]], i64 [[TMP3:%.*]]
19-
; CHECK: [[TMP4:%.*]] = load float, ptr [[TMP2]], align 4, !tbaa [[ARR_TAG]]
20-
define void @test(ptr captures(none) %0, ptr readonly captures(none) %1, ptr readonly captures(none) %2, ptr readonly captures(none) %3) local_unnamed_addr #0 {
21-
%5 = alloca [32 x float], align 4
22-
%6 = alloca [31 x float], align 4
23-
%7 = alloca [31 x float], align 4
24-
%8 = load i32, ptr %2, align 4, !tbaa !4
25-
%9 = sext i32 %8 to i64
26-
%10 = load i32, ptr %3, align 4, !tbaa !10
27-
%11 = add i32 %10, 1
28-
%12 = sext i32 %11 to i64
29-
%13 = sub nsw i64 %12, %9
30-
%14 = tail call i64 @llvm.smax.i64(i64 %13, i64 -1)
31-
%15 = add nsw i64 %14, 1
32-
%16 = alloca float, i64 %15, align 4
33-
store float 0x3E6AA51880000000, ptr %7, align 4, !tbaa !12
32+
; CHECK: [[TMP2:%.*]] = getelementptr float, ptr [[ARR_UNDER_TEST]], i64 [[TMP3:%.*]]
33+
; CHECK: [[TMP4:%.*]] = load float, ptr [[TMP2]], align 4, !tbaa [[ARR_TAG]]
34+
35+
define void @test() local_unnamed_addr #0 {
36+
%test_array_a = alloca [31 x float], align 4
37+
%test_array_b = alloca [31 x float], align 4
3438
br label %init_loop
3539

3640
init_loop:
37-
%19 = phi float [ 0x3E68DA0CA0000000, %4 ], [ %22, %init_loop ]
38-
%indvars.iv = phi i64 [ 2, %4 ], [ %indvars.iv.next, %init_loop ]
39-
%20 = add nsw i64 %indvars.iv, -1
40-
%21 = getelementptr float, ptr @data_arr, i64 %20
41-
%22 = load float, ptr %21, align 4, !tbaa !15
42-
%23 = fsub contract float %22, %19
43-
%33 = getelementptr float, ptr %7, i64 %20
44-
store float %23, ptr %33, align 4, !tbaa !12
41+
%indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %init_loop ]
4542
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
43+
%1 = getelementptr float, ptr %test_array_b, i64 %indvars.iv
44+
store float 0x3E6AA51880000000, ptr %1, align 4, !tbaa !12
4645
%exitcond.not = icmp eq i64 %indvars.iv.next, 32
4746
br i1 %exitcond.not, label %.preheader55.preheader, label %init_loop
4847

4948
.preheader55.preheader:
50-
call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(124) %6, ptr noundef nonnull align 4 dereferenceable(124) %7, i64 124, i1 false), !tbaa !22
51-
%154 = icmp sgt i64 %13, -1
52-
br i1 %154, label %loop, label %._crit_edge56
49+
call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(124) %test_array_a, ptr noundef nonnull align 4 dereferenceable(124) %test_array_b, i64 124, i1 false)
50+
br label %loop
5351

5452
loop: ; preds = %.preheader, %211
5553
%indvars.iv73 = phi i64 [ 0, %.preheader55.preheader ], [ %indvars.iv.next74, %loop ]
5654
%indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
57-
%223 = getelementptr float, ptr %6, i64 %indvars.iv73
58-
%225 = load float, ptr %223, align 4, !tbaa !31
55+
%2 = getelementptr float, ptr %test_array_a, i64 %indvars.iv73
56+
%3 = load float, ptr %2, align 4, !tbaa !31
5957
%exitcond76.not = icmp eq i64 %indvars.iv.next74, 32
6058
br i1 %exitcond76.not, label %loop, label %._crit_edge56
6159

@@ -80,20 +78,11 @@ attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite
8078
!1 = !{i32 8, !"PIC Level", i32 2}
8179
!2 = !{i32 7, !"PIE Level", i32 2}
8280
!3 = !{!"flang version 21.0.0 (https://github.com/llvm/llvm-project.git 4d79f420ce5b5100f72f720eab2d3881f97abd0d)"}
83-
!4 = !{!5, !5, i64 0}
84-
!5 = !{!"dummy arg data/param_1", !6, i64 0}
85-
!6 = !{!"dummy arg data", !7, i64 0}
8681
!7 = !{!"any data access", !8, i64 0}
8782
!8 = !{!"any access", !9, i64 0}
8883
!9 = !{!"Flang function root test"}
89-
!10 = !{!11, !11, i64 0}
90-
!11 = !{!"dummy arg data/param_2", !6, i64 0}
9184
!12 = !{!13, !13, i64 0}
9285
!13 = !{!"allocated data/test_array_a", !14, i64 0}
9386
!14 = !{!"allocated data", !7, i64 0}
94-
!15 = !{!16, !16, i64 0}
95-
!16 = !{!"global data/data_arr", !17, i64 0}
96-
!17 = !{!"global data", !7, i64 0}
97-
!22 = !{!14, !14, i64 0}
9887
!31 = !{!32, !32, i64 0}
9988
!32 = !{!"allocated data/test_array_b", !14, i64 0}

0 commit comments

Comments
 (0)