[llvm] c2f8fe7 - [EarlyCSE] Precommit test for D153151
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 14 03:47:54 PDT 2023
Author: Jay Foad
Date: 2023-07-14T11:43:41+01:00
New Revision: c2f8fe7cd82790ea422179312a706b911bc253da
URL: https://github.com/llvm/llvm-project/commit/c2f8fe7cd82790ea422179312a706b911bc253da
DIFF: https://github.com/llvm/llvm-project/commit/c2f8fe7cd82790ea422179312a706b911bc253da.diff
LOG: [EarlyCSE] Precommit test for D153151
Differential Revision: https://reviews.llvm.org/D155210
Added:
llvm/test/Transforms/EarlyCSE/AMDGPU/convergent-call.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/Transforms/EarlyCSE/AMDGPU/convergent-call.ll b/llvm/test/Transforms/EarlyCSE/AMDGPU/convergent-call.ll
new file mode 100644
index 00000000000000..b439ed64a543cb
--- /dev/null
+++ b/llvm/test/Transforms/EarlyCSE/AMDGPU/convergent-call.ll
@@ -0,0 +1,82 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
+; RUN: opt < %s -S -mtriple=amdgcn-- -passes=early-cse -earlycse-debug-hash | FileCheck %s
+
+; Should not CSE calls marked as convergent, even if the callee is not convergent.
+
+define i32 @test_read_register(i32 %cond) {
+; CHECK-LABEL: define i32 @test_read_register
+; CHECK-SAME: (i32 [[COND:%.*]]) {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[X1:%.*]] = call i32 @llvm.read_register.i32(metadata [[META0:![0-9]+]]) #[[ATTR2:[0-9]+]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[COND]], 0
+; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[END:%.*]]
+; CHECK: if:
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: [[Y2:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[X1]], [[IF]] ]
+; CHECK-NEXT: [[RET:%.*]] = add i32 [[X1]], [[Y2]]
+; CHECK-NEXT: ret i32 [[RET]]
+;
+entry:
+ ; %x = ballot operation over all lanes.
+ %x1 = call i32 @llvm.read_register.i32(metadata !{!"exec_lo"}) convergent
+ %cmp = icmp eq i32 %cond, 0
+ br i1 %cmp, label %if, label %end
+
+if:
+ ; %y = ballot operation over lanes satisfying %cond.
+ %y1 = call i32 @llvm.read_register.i32(metadata !{!"exec_lo"}) convergent
+ br label %end
+
+end:
+ %y2 = phi i32 [0, %entry], [%y1, %if]
+ %ret = add i32 %x1, %y2
+ ret i32 %ret
+}
+
+define i32 @test_read_register_samebb(i32 %cond) {
+; CHECK-LABEL: define i32 @test_read_register_samebb
+; CHECK-SAME: (i32 [[COND:%.*]]) {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[X:%.*]] = call i32 @llvm.read_register.i32(metadata [[META0]]) #[[ATTR2]]
+; CHECK-NEXT: [[RET:%.*]] = add i32 [[X]], [[X]]
+; CHECK-NEXT: ret i32 [[RET]]
+;
+entry:
+ %x = call i32 @llvm.read_register.i32(metadata !{!"exec_lo"}) convergent
+ %y = call i32 @llvm.read_register.i32(metadata !{!"exec_lo"}) convergent
+ %ret = add i32 %x, %y
+ ret i32 %ret
+}
+
+define i1 @test_live_mask(i32 %cond) {
+; CHECK-LABEL: define i1 @test_live_mask
+; CHECK-SAME: (i32 [[COND:%.*]]) {
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[X1:%.*]] = call i1 @llvm.amdgcn.live.mask() #[[ATTR2]]
+; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[COND]], 0
+; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[END:%.*]]
+; CHECK: if:
+; CHECK-NEXT: br label [[END]]
+; CHECK: end:
+; CHECK-NEXT: [[Y2:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[X1]], [[IF]] ]
+; CHECK-NEXT: [[RET:%.*]] = add i1 [[X1]], [[Y2]]
+; CHECK-NEXT: ret i1 [[RET]]
+;
+entry:
+ %x1 = call i1 @llvm.amdgcn.live.mask() convergent
+ %cmp = icmp eq i32 %cond, 0
+ br i1 %cmp, label %if, label %end
+
+if:
+ %y1 = call i1 @llvm.amdgcn.live.mask() convergent
+ br label %end
+
+end:
+ %y2 = phi i1 [0, %entry], [%y1, %if]
+ %ret = add i1 %x1, %y2
+ ret i1 %ret
+}
+
+declare i32 @llvm.read_register.i32(metadata)
+declare i1 @llvm.amdgcn.live.mask()
More information about the llvm-commits
mailing list