Skip to content

Commit db9fb63

Browse files
committed
[GVN] Add MemorySSA checks in tests 1/N
1 parent 53a395f commit db9fb63

File tree

4 files changed

+79
-32
lines changed

4 files changed

+79
-32
lines changed

llvm/test/Transforms/GVN/assume.ll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes=gvn -verify-analysis-invalidation -S | FileCheck %s
2+
; RUN: opt < %s -passes=gvn -verify-analysis-invalidation -S | FileCheck --check-prefixes=CHECK,MDEP %s
3+
; RUN: opt < %s -passes='gvn<memoryssa;no-memdep>' -verify-analysis-invalidation -S | FileCheck --check-prefixes=CHECK,MSSA %s
34

45
declare void @llvm.assume(i1)
56
declare void @use(i1)
@@ -59,3 +60,6 @@ define void @pr47496(i8 %x) {
5960
call void @use(i1 %cmp)
6061
ret void
6162
}
63+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
64+
; MDEP: {{.*}}
65+
; MSSA: {{.*}}

llvm/test/Transforms/GVN/basic.ll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
; RUN: opt < %s -passes=gvn -S | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt < %s -passes=gvn -S | FileCheck %s --check-prefixes=CHECK,MDEP
3+
; RUN: opt < %s -passes='gvn<memoryssa;no-memdep>' -S | FileCheck --check-prefixes=CHECK,MSSA %s
24

35
define i32 @main() {
6+
; CHECK-LABEL: define i32 @main() {
7+
; CHECK-NEXT: [[BLOCK1:.*:]]
8+
; CHECK-NEXT: ret i32 0
9+
;
410
block1:
5-
%z1 = bitcast i32 0 to i32
6-
br label %block2
11+
%z1 = bitcast i32 0 to i32
12+
br label %block2
713
block2:
814
%z2 = bitcast i32 0 to i32
915
ret i32 %z2
1016
}
11-
12-
; CHECK: define i32 @main() {
13-
; CHECK-NEXT: block1:
14-
; CHECK-NEXT: ret i32 0
15-
; CHECK-NEXT: }
17+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
18+
; MDEP: {{.*}}
19+
; MSSA: {{.*}}
Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -S -passes=gvn 2>&1 | FileCheck %s
2+
; RUN: opt < %s -S -passes=gvn 2>&1 | FileCheck %s --check-prefixes=CHECK,MDEP
3+
; RUN: opt < %s -S -passes='gvn<memoryssa;no-memdep>' 2>&1 | FileCheck --check-prefixes=CHECK,MSSA %s
34

45
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
56

@@ -9,10 +10,18 @@ declare noalias ptr @_Znwm(i64)
910
declare void @escape(ptr)
1011

1112
define i8 @test_malloc(ptr %p) {
12-
; CHECK-LABEL: @test_malloc(
13-
; CHECK-NEXT: [[OBJ:%.*]] = call ptr @malloc(i64 16)
14-
; CHECK-NEXT: call void @escape(ptr [[OBJ]])
15-
; CHECK-NEXT: ret i8 0
13+
; MDEP-LABEL: @test_malloc(
14+
; MDEP-NEXT: [[OBJ:%.*]] = call ptr @malloc(i64 16)
15+
; MDEP-NEXT: call void @escape(ptr [[OBJ]])
16+
; MDEP-NEXT: ret i8 0
17+
;
18+
; MSSA-LABEL: @test_malloc(
19+
; MSSA-NEXT: [[V1:%.*]] = load i8, ptr [[P:%.*]], align 1
20+
; MSSA-NEXT: [[OBJ:%.*]] = call ptr @malloc(i64 16)
21+
; MSSA-NEXT: [[V2:%.*]] = load i8, ptr [[P]], align 1
22+
; MSSA-NEXT: [[SUB:%.*]] = sub i8 [[V1]], [[V2]]
23+
; MSSA-NEXT: call void @escape(ptr [[OBJ]])
24+
; MSSA-NEXT: ret i8 [[SUB]]
1625
;
1726
%v1 = load i8, ptr %p
1827
%obj = call ptr @malloc(i64 16)
@@ -23,10 +32,18 @@ define i8 @test_malloc(ptr %p) {
2332
}
2433

2534
define i8 @test_calloc(ptr %p) {
26-
; CHECK-LABEL: @test_calloc(
27-
; CHECK-NEXT: [[OBJ:%.*]] = call ptr @calloc(i64 1, i64 16)
28-
; CHECK-NEXT: call void @escape(ptr [[OBJ]])
29-
; CHECK-NEXT: ret i8 0
35+
; MDEP-LABEL: @test_calloc(
36+
; MDEP-NEXT: [[OBJ:%.*]] = call ptr @calloc(i64 1, i64 16)
37+
; MDEP-NEXT: call void @escape(ptr [[OBJ]])
38+
; MDEP-NEXT: ret i8 0
39+
;
40+
; MSSA-LABEL: @test_calloc(
41+
; MSSA-NEXT: [[V1:%.*]] = load i8, ptr [[P:%.*]], align 1
42+
; MSSA-NEXT: [[OBJ:%.*]] = call ptr @calloc(i64 1, i64 16)
43+
; MSSA-NEXT: [[V2:%.*]] = load i8, ptr [[P]], align 1
44+
; MSSA-NEXT: [[SUB:%.*]] = sub i8 [[V1]], [[V2]]
45+
; MSSA-NEXT: call void @escape(ptr [[OBJ]])
46+
; MSSA-NEXT: ret i8 [[SUB]]
3047
;
3148
%v1 = load i8, ptr %p
3249
%obj = call ptr @calloc(i64 1, i64 16)
@@ -37,10 +54,18 @@ define i8 @test_calloc(ptr %p) {
3754
}
3855

3956
define i8 @test_opnew(ptr %p) {
40-
; CHECK-LABEL: @test_opnew(
41-
; CHECK-NEXT: [[OBJ:%.*]] = call ptr @_Znwm(i64 16)
42-
; CHECK-NEXT: call void @escape(ptr [[OBJ]])
43-
; CHECK-NEXT: ret i8 0
57+
; MDEP-LABEL: @test_opnew(
58+
; MDEP-NEXT: [[OBJ:%.*]] = call ptr @_Znwm(i64 16)
59+
; MDEP-NEXT: call void @escape(ptr [[OBJ]])
60+
; MDEP-NEXT: ret i8 0
61+
;
62+
; MSSA-LABEL: @test_opnew(
63+
; MSSA-NEXT: [[V1:%.*]] = load i8, ptr [[P:%.*]], align 1
64+
; MSSA-NEXT: [[OBJ:%.*]] = call ptr @_Znwm(i64 16)
65+
; MSSA-NEXT: [[V2:%.*]] = load i8, ptr [[P]], align 1
66+
; MSSA-NEXT: [[SUB:%.*]] = sub i8 [[V1]], [[V2]]
67+
; MSSA-NEXT: call void @escape(ptr [[OBJ]])
68+
; MSSA-NEXT: ret i8 [[SUB]]
4469
;
4570
%v1 = load i8, ptr %p
4671
%obj = call ptr @_Znwm(i64 16)
@@ -49,5 +74,5 @@ define i8 @test_opnew(ptr %p) {
4974
call void @escape(ptr %obj)
5075
ret i8 %sub
5176
}
52-
53-
77+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
78+
; CHECK: {{.*}}

llvm/test/Transforms/GVN/pr14166.ll

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
1-
; RUN: opt -disable-basic-aa -passes=gvn -S < %s | FileCheck %s
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -disable-basic-aa -passes=gvn -S < %s | FileCheck %s --check-prefixes=CHECK,MDEP
3+
; RUN: opt -disable-basic-aa -passes='gvn<memoryssa;no-memdep>' -S < %s | FileCheck --check-prefixes=CHECK,MSSA %s
24
target datalayout = "e-p:32:32:32"
35
define <2 x i32> @test1() {
6+
; MDEP-LABEL: define <2 x i32> @test1() {
7+
; MDEP-NEXT: [[V1:%.*]] = alloca <2 x i32>, align 8
8+
; MDEP-NEXT: call void @anything(ptr [[V1]])
9+
; MDEP-NEXT: [[V2:%.*]] = load <2 x i32>, ptr [[V1]], align 8
10+
; MDEP-NEXT: [[V3:%.*]] = inttoptr <2 x i32> [[V2]] to <2 x ptr>
11+
; MDEP-NEXT: store <2 x ptr> [[V3]], ptr [[V1]], align 8
12+
; MDEP-NEXT: [[TMP1:%.*]] = bitcast <2 x i32> [[V2]] to i64
13+
; MDEP-NEXT: ret <2 x i32> [[V2]]
14+
;
15+
; MSSA-LABEL: define <2 x i32> @test1() {
16+
; MSSA-NEXT: [[V1:%.*]] = alloca <2 x i32>, align 8
17+
; MSSA-NEXT: call void @anything(ptr [[V1]])
18+
; MSSA-NEXT: [[V2:%.*]] = load <2 x i32>, ptr [[V1]], align 8
19+
; MSSA-NEXT: [[V3:%.*]] = inttoptr <2 x i32> [[V2]] to <2 x ptr>
20+
; MSSA-NEXT: store <2 x ptr> [[V3]], ptr [[V1]], align 8
21+
; MSSA-NEXT: [[V5:%.*]] = load <2 x i32>, ptr [[V1]], align 8
22+
; MSSA-NEXT: ret <2 x i32> [[V5]]
423
%v1 = alloca <2 x i32>
524
call void @anything(ptr %v1)
625
%v2 = load <2 x i32>, ptr %v1
726
%v3 = inttoptr <2 x i32> %v2 to <2 x ptr>
827
store <2 x ptr> %v3, ptr %v1
928
%v5 = load <2 x i32>, ptr %v1
1029
ret <2 x i32> %v5
11-
; CHECK-LABEL: @test1(
12-
; CHECK: %v1 = alloca <2 x i32>
13-
; CHECK: call void @anything(ptr %v1)
14-
; CHECK: %v2 = load <2 x i32>, ptr %v1
15-
; CHECK: %v3 = inttoptr <2 x i32> %v2 to <2 x ptr>
16-
; CHECK: store <2 x ptr> %v3, ptr %v1
17-
; CHECK: ret <2 x i32> %v2
1830
}
1931

2032
declare void @anything(ptr)
2133

34+
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
35+
; CHECK: {{.*}}

0 commit comments

Comments
 (0)