[llvm] 998e823 - [GVN] Add additional metadata combining tests (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 20 03:18:02 PDT 2023
Author: Nikita Popov
Date: 2023-04-20T12:17:53+02:00
New Revision: 998e8236133ed57792f4659221552f12b4c6d889
URL: https://github.com/llvm/llvm-project/commit/998e8236133ed57792f4659221552f12b4c6d889
DIFF: https://github.com/llvm/llvm-project/commit/998e8236133ed57792f4659221552f12b4c6d889.diff
LOG: [GVN] Add additional metadata combining tests (NFC)
Added:
Modified:
llvm/test/Transforms/GVN/metadata.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/GVN/metadata.ll b/llvm/test/Transforms/GVN/metadata.ll
index 8e6fee58adbc1..8034e5dc4fb83 100644
--- a/llvm/test/Transforms/GVN/metadata.ll
+++ b/llvm/test/Transforms/GVN/metadata.ll
@@ -1,9 +1,9 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --version 2
; RUN: opt -passes=gvn -S < %s | FileCheck %s
-declare void @use.ptr(ptr)
-declare void @use.i64(i64)
-declare void @use.i32(i32)
+declare void @use.ptr(ptr) memory(none)
+declare void @use.i64(i64) memory(none)
+declare void @use.i32(i32) memory(none)
define i32 @test1(ptr %p) {
; CHECK-LABEL: define i32 @test1
@@ -284,6 +284,135 @@ define void @load_i64_range_to_i32_range(ptr %p) {
ret void
}
+define i64 @load_is_stored(ptr %p, ptr %p2) {
+; CHECK-LABEL: define i64 @load_is_stored
+; CHECK-SAME: (ptr [[P:%.*]], ptr [[P2:%.*]]) {
+; CHECK-NEXT: [[V1:%.*]] = load i64, ptr [[P]], align 4
+; CHECK-NEXT: store i64 [[V1]], ptr [[P2]], align 4
+; CHECK-NEXT: ret i64 [[V1]]
+;
+ %v1 = load i64, ptr %p, !range !{i64 0, i64 10}
+ store i64 %v1, ptr %p2
+ %v2 = load i64, ptr %p2
+ ret i64 %v2
+}
+
+define void @non_local_dominating(i1 %c, ptr %p) {
+; CHECK-LABEL: define void @non_local_dominating
+; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]]) {
+; CHECK-NEXT: [[V1:%.*]] = load i64, ptr [[P]], align 4, !range [[RNG8:![0-9]+]]
+; CHECK-NEXT: br i1 [[C]], label [[IF:%.*]], label [[JOIN:%.*]]
+; CHECK: if:
+; CHECK-NEXT: br label [[JOIN]]
+; CHECK: join:
+; CHECK-NEXT: call void @use.i64(i64 [[V1]])
+; CHECK-NEXT: call void @use.i64(i64 [[V1]])
+; CHECK-NEXT: ret void
+;
+ %v1 = load i64, ptr %p, !range !{i64 0, i64 10}
+ br i1 %c, label %if, label %join
+
+if:
+ br label %join
+
+join:
+ %v2 = load i64, ptr %p, !range !{i64 20, i64 30}
+ call void @use.i64(i64 %v1)
+ call void @use.i64(i64 %v2)
+ ret void
+}
+
+define void @non_local_non_dominating(i1 %c, ptr %p) {
+; CHECK-LABEL: define void @non_local_non_dominating
+; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]]) {
+; CHECK-NEXT: br i1 [[C]], label [[IF:%.*]], label [[ELSE:%.*]]
+; CHECK: if:
+; CHECK-NEXT: [[V1:%.*]] = load i64, ptr [[P]], align 4, !range [[RNG8]]
+; CHECK-NEXT: call void @use.i64(i64 [[V1]])
+; CHECK-NEXT: br label [[JOIN:%.*]]
+; CHECK: else:
+; CHECK-NEXT: [[V2:%.*]] = load i64, ptr [[P]], align 4, !range [[RNG9:![0-9]+]]
+; CHECK-NEXT: call void @use.i64(i64 [[V2]])
+; CHECK-NEXT: br label [[JOIN]]
+; CHECK: join:
+; CHECK-NEXT: [[V3:%.*]] = phi i64 [ [[V2]], [[ELSE]] ], [ [[V1]], [[IF]] ]
+; CHECK-NEXT: call void @use.i64(i64 [[V3]])
+; CHECK-NEXT: ret void
+;
+ br i1 %c, label %if, label %else
+
+if:
+ %v1 = load i64, ptr %p, !range !{i64 0, i64 10}
+ call void @use.i64(i64 %v1)
+ br label %join
+
+else:
+ %v2 = load i64, ptr %p, !range !{i64 10, i64 20}
+ call void @use.i64(i64 %v2)
+ br label %join
+
+join:
+ %v3 = load i64, ptr %p, !range !{i64 20, i64 30}
+ call void @use.i64(i64 %v3)
+ ret void
+}
+
+define void @non_local_coerced(i1 %c, ptr %p) {
+; CHECK-LABEL: define void @non_local_coerced
+; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]]) {
+; CHECK-NEXT: [[V1_PTR:%.*]] = load ptr, ptr [[P]], align 8
+; CHECK-NEXT: [[V1:%.*]] = ptrtoint ptr [[V1_PTR]] to i64
+; CHECK-NEXT: br i1 [[C]], label [[IF:%.*]], label [[JOIN:%.*]]
+; CHECK: if:
+; CHECK-NEXT: br label [[JOIN]]
+; CHECK: join:
+; CHECK-NEXT: call void @use.i64(i64 [[V1]])
+; CHECK-NEXT: call void @use.i64(i64 [[V1]])
+; CHECK-NEXT: ret void
+;
+ %v1.ptr = load ptr, ptr %p, !nonnull !{}
+ %v1 = ptrtoint ptr %v1.ptr to i64
+ br i1 %c, label %if, label %join
+
+if:
+ br label %join
+
+join:
+ %v2 = load i64, ptr %p, !range !{i64 20, i64 30}
+ call void @use.i64(i64 %v1)
+ call void @use.i64(i64 %v2)
+ ret void
+}
+
+define void @non_local_pre(i1 %c, ptr %p) {
+; CHECK-LABEL: define void @non_local_pre
+; CHECK-SAME: (i1 [[C:%.*]], ptr [[P:%.*]]) {
+; CHECK-NEXT: br i1 [[C]], label [[IF:%.*]], label [[DOTJOIN_CRIT_EDGE:%.*]]
+; CHECK: .join_crit_edge:
+; CHECK-NEXT: [[V2_PRE:%.*]] = load i64, ptr [[P]], align 4, !range [[RNG10:![0-9]+]]
+; CHECK-NEXT: br label [[JOIN:%.*]]
+; CHECK: if:
+; CHECK-NEXT: [[V1:%.*]] = load i64, ptr [[P]], align 4, !range [[RNG8]]
+; CHECK-NEXT: call void @use.i64(i64 [[V1]])
+; CHECK-NEXT: br label [[JOIN]]
+; CHECK: join:
+; CHECK-NEXT: [[V2:%.*]] = phi i64 [ [[V2_PRE]], [[DOTJOIN_CRIT_EDGE]] ], [ [[V1]], [[IF]] ]
+; CHECK-NEXT: call void @use.i64(i64 [[V2]])
+; CHECK-NEXT: ret void
+;
+ br i1 %c, label %if, label %join
+
+if:
+ %v1 = load i64, ptr %p, !range !{i64 0, i64 10}
+ call void @use.i64(i64 %v1)
+ br label %join
+
+join:
+ %v2 = load i64, ptr %p, !range !{i64 20, i64 30}
+ call void @use.i64(i64 %v2)
+ ret void
+}
+
!0 = !{i32 0, i32 2}
!1 = !{i32 3, i32 5}
!2 = !{i32 2, i32 5}
@@ -297,6 +426,8 @@ define void @load_i64_range_to_i32_range(ptr %p) {
!10 = !{i32 5, i32 1}
!11 = !{}
;.
+; CHECK: attributes #[[ATTR0:[0-9]+]] = { memory(none) }
+;.
; CHECK: [[RNG0]] = !{i32 0, i32 2}
; CHECK: [[RNG1]] = !{i32 0, i32 2, i32 3, i32 5}
; CHECK: [[RNG2]] = !{i32 0, i32 5}
@@ -305,4 +436,7 @@ define void @load_i64_range_to_i32_range(ptr %p) {
; CHECK: [[RNG5]] = !{i32 3, i32 4, i32 5, i32 2}
; CHECK: [[META6:![0-9]+]] = !{}
; CHECK: [[META7:![0-9]+]] = !{i64 10}
+; CHECK: [[RNG8]] = !{i64 0, i64 10}
+; CHECK: [[RNG9]] = !{i64 10, i64 20}
+; CHECK: [[RNG10]] = !{i64 20, i64 30}
;.
More information about the llvm-commits
mailing list