[llvm] 8998b81 - [tests] Expand coverage of gc.relocate CSE in early-cse
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 4 12:13:04 PST 2021
Author: Philip Reames
Date: 2021-03-04T12:12:55-08:00
New Revision: 8998b811c936aaa6e35abdb5b2b8a302ac56addf
URL: https://github.com/llvm/llvm-project/commit/8998b811c936aaa6e35abdb5b2b8a302ac56addf
DIFF: https://github.com/llvm/llvm-project/commit/8998b811c936aaa6e35abdb5b2b8a302ac56addf.diff
LOG: [tests] Expand coverage of gc.relocate CSE in early-cse
Added:
Modified:
llvm/test/Transforms/EarlyCSE/gc_relocate.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/EarlyCSE/gc_relocate.ll b/llvm/test/Transforms/EarlyCSE/gc_relocate.ll
index 435b081a9a20..779edc837fc4 100644
--- a/llvm/test/Transforms/EarlyCSE/gc_relocate.ll
+++ b/llvm/test/Transforms/EarlyCSE/gc_relocate.ll
@@ -4,6 +4,25 @@
declare void @func()
declare i32 @"personality_function"()
+define i1 @test_trivial(i32 addrspace(1)* %in) gc "statepoint-example" {
+; CHECK-LABEL: @test_trivial(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SAFEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i32 addrspace(1)* [[IN:%.*]]) ]
+; CHECK-NEXT: [[A:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
+; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 addrspace(1)* [[A]], null
+; CHECK-NEXT: ret i1 [[CMP1]]
+;
+entry:
+ %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(i32 addrspace(1)* %in)]
+ %a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
+ %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
+ %cmp1 = icmp eq i32 addrspace(1)* %a, null
+ %cmp2 = icmp eq i32 addrspace(1)* %b, null
+ %cmp = and i1 %cmp1, %cmp2
+ ret i1 %cmp
+}
+
+
define i1 @test_call(i32 addrspace(1)* %in) gc "statepoint-example" {
; CHECK-LABEL: @test_call(
; CHECK-NEXT: entry:
@@ -85,5 +104,34 @@ exceptional_return:
ret i32 addrspace(1)* %out1
}
+; negative test - neither dominates the other
+define i1 @test_non_dominating(i1 %c, i32 addrspace(1)* %in) gc "statepoint-example" {
+;
+; CHECK-LABEL: @test_non_dominating(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[SAFEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @func, i32 0, i32 0, i32 0, i32 0) [ "gc-live"(i32 addrspace(1)* [[IN:%.*]]) ]
+; CHECK-NEXT: br i1 [[C:%.*]], label [[TAKEN:%.*]], label [[UNTAKEN:%.*]]
+; CHECK: taken:
+; CHECK-NEXT: [[A:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 addrspace(1)* [[A]], null
+; CHECK-NEXT: ret i1 [[CMP]]
+; CHECK: untaken:
+; CHECK-NEXT: [[B:%.*]] = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token [[SAFEPOINT_TOKEN]], i32 0, i32 0)
+; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 addrspace(1)* [[B]], null
+; CHECK-NEXT: ret i1 [[CMP2]]
+;
+entry:
+ %safepoint_token = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @func, i32 0, i32 0, i32 0, i32 0) ["gc-live"(i32 addrspace(1)* %in)]
+ br i1 %c, label %taken, label %untaken
+taken:
+ %a = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
+ %cmp = icmp eq i32 addrspace(1)* %a, null
+ ret i1 %cmp
+untaken:
+ %b = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 0, i32 0)
+ %cmp2 = icmp eq i32 addrspace(1)* %b, null
+ ret i1 %cmp2
+}
+
declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token, i32, i32)
More information about the llvm-commits
mailing list