[PATCH] D129025: [SimplifyCFG] Skip hoisting common instructions that return token type
Yuanfang Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 4 12:48:02 PDT 2022
ychen updated this revision to Diff 442137.
ychen added a comment.
- rebase
- simplify the test case
- use update_test_checks.py
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129025/new/
https://reviews.llvm.org/D129025
Files:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll
Index: llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SimplifyCFG/hoist-skip-token.ll
@@ -0,0 +1,39 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes='simplifycfg<hoist-common-insts>' -S | FileCheck %s
+
+declare token @llvm.coro.save(ptr)
+declare i8 @llvm.coro.suspend(token, i1)
+
+define void @f(i32 %x) {
+; CHECK-LABEL: @f(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[X:%.*]], 0
+; CHECK-NEXT: br i1 [[CMP]], label [[AWAIT_SUSPEND:%.*]], label [[FINAL_SUSPEND:%.*]]
+; CHECK: await.suspend:
+; CHECK-NEXT: [[TMP0:%.*]] = call token @llvm.coro.save(ptr null)
+; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.coro.suspend(token [[TMP0]], i1 false)
+; CHECK-NEXT: br label [[CORO_RET:%.*]]
+; CHECK: final.suspend:
+; CHECK-NEXT: [[TMP2:%.*]] = call token @llvm.coro.save(ptr null)
+; CHECK-NEXT: [[TMP3:%.*]] = call i8 @llvm.coro.suspend(token [[TMP2]], i1 true)
+; CHECK-NEXT: br label [[CORO_RET]]
+; CHECK: coro.ret:
+; CHECK-NEXT: ret void
+;
+entry:
+ %cmp = icmp slt i32 %x, 0
+ br i1 %cmp, label %await.suspend, label %final.suspend
+
+await.suspend:
+ %0 = call token @llvm.coro.save(ptr null)
+ %1 = call i8 @llvm.coro.suspend(token %0, i1 false)
+ br label %coro.ret
+
+final.suspend:
+ %2 = call token @llvm.coro.save(ptr null)
+ %3 = call i8 @llvm.coro.suspend(token %2, i1 true)
+ br label %coro.ret
+
+coro.ret:
+ ret void
+}
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1473,7 +1473,8 @@
while (isa<DbgInfoIntrinsic>(I2))
I2 = &*BB2_Itr++;
}
- if (isa<PHINode>(I1) || !I1->isIdenticalToWhenDefined(I2))
+ if (isa<PHINode>(I1) || !I1->isIdenticalToWhenDefined(I2) ||
+ I1->getType()->isTokenTy() || I2->getType()->isTokenTy())
return false;
BasicBlock *BIParent = BI->getParent();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129025.442137.patch
Type: text/x-patch
Size: 2137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220704/60c6ceec/attachment.bin>
More information about the llvm-commits
mailing list