[llvm] ad0827d - [GVN] Add MemorySSA checks in tests 1/N (#130261)

via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 20 23:30:26 PDT 2025


Author: Madhur Amilkanthwar
Date: 2025-03-21T12:00:22+05:30
New Revision: ad0827d364293a42540885ae41b78995e2818581

URL: https://github.com/llvm/llvm-project/commit/ad0827d364293a42540885ae41b78995e2818581
DIFF: https://github.com/llvm/llvm-project/commit/ad0827d364293a42540885ae41b78995e2818581.diff

LOG: [GVN] Add MemorySSA checks in tests 1/N (#130261)

Add MemorySSA checks in some GVN tests. This is first patch of the series and many more might come based on tests pass/fail.

Added: 
    

Modified: 
    llvm/test/Transforms/GVN/assume.ll
    llvm/test/Transforms/GVN/basic.ll
    llvm/test/Transforms/GVN/nonescaping.ll
    llvm/test/Transforms/GVN/pr14166.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/GVN/assume.ll b/llvm/test/Transforms/GVN/assume.ll
index 6cb4c871750d6..1498aa4fa7b0b 100644
--- a/llvm/test/Transforms/GVN/assume.ll
+++ b/llvm/test/Transforms/GVN/assume.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -passes=gvn -verify-analysis-invalidation -S | FileCheck %s
+; RUN: opt < %s -passes=gvn -verify-analysis-invalidation -S | FileCheck --check-prefixes=CHECK,MDEP %s
+; RUN: opt < %s -passes='gvn<memoryssa;no-memdep>' -verify-analysis-invalidation -S | FileCheck --check-prefixes=CHECK,MSSA %s
 
 declare void @llvm.assume(i1)
 declare void @use(i1)
@@ -59,3 +60,6 @@ define void @pr47496(i8 %x) {
   call void @use(i1 %cmp)
   ret void
 }
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; MDEP: {{.*}}
+; MSSA: {{.*}}

diff  --git a/llvm/test/Transforms/GVN/basic.ll b/llvm/test/Transforms/GVN/basic.ll
index 09155bf4cf2fd..c1a358af903f4 100644
--- a/llvm/test/Transforms/GVN/basic.ll
+++ b/llvm/test/Transforms/GVN/basic.ll
@@ -1,15 +1,19 @@
-; RUN: opt < %s -passes=gvn -S | FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt < %s -passes=gvn -S | FileCheck %s --check-prefixes=CHECK,MDEP
+; RUN: opt < %s -passes='gvn<memoryssa;no-memdep>' -S | FileCheck --check-prefixes=CHECK,MSSA %s
 
 define i32 @main() {
+; CHECK-LABEL: define i32 @main() {
+; CHECK-NEXT:  [[BLOCK1:.*:]]
+; CHECK-NEXT:    ret i32 0
+;
 block1:
-	%z1 = bitcast i32 0 to i32
-	br label %block2
+  %z1 = bitcast i32 0 to i32
+  br label %block2
 block2:
   %z2 = bitcast i32 0 to i32
   ret i32 %z2
 }
-
-; CHECK: define i32 @main() {
-; CHECK-NEXT: block1:
-; CHECK-NEXT:   ret i32 0
-; CHECK-NEXT: }
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; MDEP: {{.*}}
+; MSSA: {{.*}}

diff  --git a/llvm/test/Transforms/GVN/nonescaping.ll b/llvm/test/Transforms/GVN/nonescaping.ll
index ad6fa1db0f93e..29137556f14de 100644
--- a/llvm/test/Transforms/GVN/nonescaping.ll
+++ b/llvm/test/Transforms/GVN/nonescaping.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -S -passes=gvn 2>&1 | FileCheck %s
+; RUN: opt < %s -S -passes=gvn 2>&1 | FileCheck %s --check-prefixes=CHECK,MDEP
+; RUN: opt < %s -S -passes='gvn<memoryssa;no-memdep>' 2>&1 | FileCheck --check-prefixes=CHECK,MSSA %s
 
 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"
 
@@ -9,10 +10,18 @@ declare noalias ptr @_Znwm(i64)
 declare void @escape(ptr)
 
 define i8 @test_malloc(ptr %p) {
-; CHECK-LABEL: @test_malloc(
-; CHECK-NEXT:    [[OBJ:%.*]] = call ptr @malloc(i64 16)
-; CHECK-NEXT:    call void @escape(ptr [[OBJ]])
-; CHECK-NEXT:    ret i8 0
+; MDEP-LABEL: @test_malloc(
+; MDEP-NEXT:    [[OBJ:%.*]] = call ptr @malloc(i64 16)
+; MDEP-NEXT:    call void @escape(ptr [[OBJ]])
+; MDEP-NEXT:    ret i8 0
+;
+; MSSA-LABEL: @test_malloc(
+; MSSA-NEXT:    [[V1:%.*]] = load i8, ptr [[P:%.*]], align 1
+; MSSA-NEXT:    [[OBJ:%.*]] = call ptr @malloc(i64 16)
+; MSSA-NEXT:    [[V2:%.*]] = load i8, ptr [[P]], align 1
+; MSSA-NEXT:    [[SUB:%.*]] = sub i8 [[V1]], [[V2]]
+; MSSA-NEXT:    call void @escape(ptr [[OBJ]])
+; MSSA-NEXT:    ret i8 [[SUB]]
 ;
   %v1 = load i8, ptr %p
   %obj = call ptr @malloc(i64 16)
@@ -23,10 +32,18 @@ define i8 @test_malloc(ptr %p) {
 }
 
 define i8 @test_calloc(ptr %p) {
-; CHECK-LABEL: @test_calloc(
-; CHECK-NEXT:    [[OBJ:%.*]] = call ptr @calloc(i64 1, i64 16)
-; CHECK-NEXT:    call void @escape(ptr [[OBJ]])
-; CHECK-NEXT:    ret i8 0
+; MDEP-LABEL: @test_calloc(
+; MDEP-NEXT:    [[OBJ:%.*]] = call ptr @calloc(i64 1, i64 16)
+; MDEP-NEXT:    call void @escape(ptr [[OBJ]])
+; MDEP-NEXT:    ret i8 0
+;
+; MSSA-LABEL: @test_calloc(
+; MSSA-NEXT:    [[V1:%.*]] = load i8, ptr [[P:%.*]], align 1
+; MSSA-NEXT:    [[OBJ:%.*]] = call ptr @calloc(i64 1, i64 16)
+; MSSA-NEXT:    [[V2:%.*]] = load i8, ptr [[P]], align 1
+; MSSA-NEXT:    [[SUB:%.*]] = sub i8 [[V1]], [[V2]]
+; MSSA-NEXT:    call void @escape(ptr [[OBJ]])
+; MSSA-NEXT:    ret i8 [[SUB]]
 ;
   %v1 = load i8, ptr %p
   %obj = call ptr @calloc(i64 1, i64 16)
@@ -37,10 +54,18 @@ define i8 @test_calloc(ptr %p) {
 }
 
 define i8 @test_opnew(ptr %p) {
-; CHECK-LABEL: @test_opnew(
-; CHECK-NEXT:    [[OBJ:%.*]] = call ptr @_Znwm(i64 16)
-; CHECK-NEXT:    call void @escape(ptr [[OBJ]])
-; CHECK-NEXT:    ret i8 0
+; MDEP-LABEL: @test_opnew(
+; MDEP-NEXT:    [[OBJ:%.*]] = call ptr @_Znwm(i64 16)
+; MDEP-NEXT:    call void @escape(ptr [[OBJ]])
+; MDEP-NEXT:    ret i8 0
+;
+; MSSA-LABEL: @test_opnew(
+; MSSA-NEXT:    [[V1:%.*]] = load i8, ptr [[P:%.*]], align 1
+; MSSA-NEXT:    [[OBJ:%.*]] = call ptr @_Znwm(i64 16)
+; MSSA-NEXT:    [[V2:%.*]] = load i8, ptr [[P]], align 1
+; MSSA-NEXT:    [[SUB:%.*]] = sub i8 [[V1]], [[V2]]
+; MSSA-NEXT:    call void @escape(ptr [[OBJ]])
+; MSSA-NEXT:    ret i8 [[SUB]]
 ;
   %v1 = load i8, ptr %p
   %obj = call ptr @_Znwm(i64 16)
@@ -49,5 +74,5 @@ define i8 @test_opnew(ptr %p) {
   call void @escape(ptr %obj)
   ret i8 %sub
 }
-
-
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; CHECK: {{.*}}

diff  --git a/llvm/test/Transforms/GVN/pr14166.ll b/llvm/test/Transforms/GVN/pr14166.ll
index 3379a5f604b0b..bbc8c89ddaa63 100644
--- a/llvm/test/Transforms/GVN/pr14166.ll
+++ b/llvm/test/Transforms/GVN/pr14166.ll
@@ -1,6 +1,25 @@
-; RUN: opt -disable-basic-aa -passes=gvn -S < %s | FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -disable-basic-aa -passes=gvn -S < %s | FileCheck %s --check-prefixes=CHECK,MDEP
+; RUN: opt -disable-basic-aa -passes='gvn<memoryssa;no-memdep>' -S < %s | FileCheck --check-prefixes=CHECK,MSSA %s
 target datalayout = "e-p:32:32:32"
 define <2 x i32> @test1() {
+; MDEP-LABEL: define <2 x i32> @test1() {
+; MDEP-NEXT:    [[V1:%.*]] = alloca <2 x i32>, align 8
+; MDEP-NEXT:    call void @anything(ptr [[V1]])
+; MDEP-NEXT:    [[V2:%.*]] = load <2 x i32>, ptr [[V1]], align 8
+; MDEP-NEXT:    [[V3:%.*]] = inttoptr <2 x i32> [[V2]] to <2 x ptr>
+; MDEP-NEXT:    store <2 x ptr> [[V3]], ptr [[V1]], align 8
+; MDEP-NEXT:    [[TMP1:%.*]] = bitcast <2 x i32> [[V2]] to i64
+; MDEP-NEXT:    ret <2 x i32> [[V2]]
+;
+; MSSA-LABEL: define <2 x i32> @test1() {
+; MSSA-NEXT:    [[V1:%.*]] = alloca <2 x i32>, align 8
+; MSSA-NEXT:    call void @anything(ptr [[V1]])
+; MSSA-NEXT:    [[V2:%.*]] = load <2 x i32>, ptr [[V1]], align 8
+; MSSA-NEXT:    [[V3:%.*]] = inttoptr <2 x i32> [[V2]] to <2 x ptr>
+; MSSA-NEXT:    store <2 x ptr> [[V3]], ptr [[V1]], align 8
+; MSSA-NEXT:    [[V5:%.*]] = load <2 x i32>, ptr [[V1]], align 8
+; MSSA-NEXT:    ret <2 x i32> [[V5]]
   %v1 = alloca <2 x i32>
   call void @anything(ptr %v1)
   %v2 = load <2 x i32>, ptr %v1
@@ -8,14 +27,9 @@ define <2 x i32> @test1() {
   store <2 x ptr> %v3, ptr %v1
   %v5 = load <2 x i32>, ptr %v1
   ret <2 x i32> %v5
-; CHECK-LABEL: @test1(
-; CHECK: %v1 = alloca <2 x i32>
-; CHECK: call void @anything(ptr %v1)
-; CHECK: %v2 = load <2 x i32>, ptr %v1
-; CHECK: %v3 = inttoptr <2 x i32> %v2 to <2 x ptr>
-; CHECK: store <2 x ptr> %v3, ptr %v1
-; CHECK: ret <2 x i32> %v2
 }
 
 declare void @anything(ptr)
 
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; CHECK: {{.*}}


        


More information about the llvm-commits mailing list