[llvm] 178270b - [GVN] Add additional captured before tests (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 23 07:45:23 PDT 2023
Author: Nikita Popov
Date: 2023-10-23T16:45:14+02:00
New Revision: 178270b7bebe863d8a55fb18cba7aa304ab919e1
URL: https://github.com/llvm/llvm-project/commit/178270b7bebe863d8a55fb18cba7aa304ab919e1
DIFF: https://github.com/llvm/llvm-project/commit/178270b7bebe863d8a55fb18cba7aa304ab919e1.diff
LOG: [GVN] Add additional captured before tests (NFC)
Added:
Modified:
llvm/test/Transforms/GVN/captured-before.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/GVN/captured-before.ll b/llvm/test/Transforms/GVN/captured-before.ll
index 6d012edea34610f..6bf95de9ee0b5f4 100644
--- a/llvm/test/Transforms/GVN/captured-before.ll
+++ b/llvm/test/Transforms/GVN/captured-before.ll
@@ -77,3 +77,59 @@ define i32 @test_store_after_capture(ptr %p) {
%v = load i32, ptr %a
ret i32 %v
}
+
+define i32 @test_capture_readonly() {
+; CHECK-LABEL: define i32 @test_capture_readonly() {
+; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
+; CHECK-NEXT: store i32 123, ptr [[A]], align 4
+; CHECK-NEXT: call void @capture(ptr readonly [[A]])
+; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[A]], align 4
+; CHECK-NEXT: ret i32 [[V]]
+;
+ %a = alloca i32
+ store i32 123, ptr %a
+ call void @capture(ptr readonly %a)
+ %v = load i32, ptr %a
+ ret i32 %v
+}
+
+define i32 @test_capture_readonly_with_following_call() {
+; CHECK-LABEL: define i32 @test_capture_readonly_with_following_call() {
+; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
+; CHECK-NEXT: store i32 123, ptr [[A]], align 4
+; CHECK-NEXT: call void @capture(ptr readonly [[A]])
+; CHECK-NEXT: call void @some_call()
+; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[A]], align 4
+; CHECK-NEXT: ret i32 [[V]]
+;
+ %a = alloca i32
+ store i32 123, ptr %a
+ call void @capture(ptr readonly %a)
+ call void @some_call()
+ %v = load i32, ptr %a
+ ret i32 %v
+}
+
+declare void @use(i32)
+
+define i32 @test_capture_readonly_in_loop() {
+; CHECK-LABEL: define i32 @test_capture_readonly_in_loop() {
+; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
+; CHECK-NEXT: store i32 123, ptr [[A]], align 4
+; CHECK-NEXT: br label [[LOOP:%.*]]
+; CHECK: loop:
+; CHECK-NEXT: call void @capture(ptr readonly [[A]])
+; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[A]], align 4
+; CHECK-NEXT: call void @use(i32 [[V]]) #[[ATTR0:[0-9]+]]
+; CHECK-NEXT: br label [[LOOP]]
+;
+ %a = alloca i32
+ store i32 123, ptr %a
+ br label %loop
+
+loop:
+ call void @capture(ptr readonly %a)
+ %v = load i32, ptr %a
+ call void @use(i32 %v) memory(none)
+ br label %loop
+}
More information about the llvm-commits
mailing list