[PATCH] D153151: [EarlyCSE] Do not CSE convergent readnone calls
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 16 09:13:06 PDT 2023
foad created this revision.
foad added reviewers: nhaehnle, sameerds, yaxunl, arsenm.
Herald added subscribers: StephenFan, kerbowa, hiraditya, jvesely.
Herald added a project: All.
foad requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
This is an update to D149348 <https://reviews.llvm.org/D149348> which tried to prevent CSEing convergent
calls in different basic blocks, but missed that readnone calls were
handled earlier because they satisfied SimpleValue::canHandle or
CallValue::canHandle.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153151
Files:
llvm/lib/Transforms/Scalar/EarlyCSE.cpp
llvm/test/Transforms/EarlyCSE/AMDGPU/convergent-call.ll
Index: llvm/test/Transforms/EarlyCSE/AMDGPU/convergent-call.ll
===================================================================
--- llvm/test/Transforms/EarlyCSE/AMDGPU/convergent-call.ll
+++ llvm/test/Transforms/EarlyCSE/AMDGPU/convergent-call.ll
@@ -10,9 +10,10 @@
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[COND]], 0
; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[END:%.*]]
; CHECK: if:
+; CHECK-NEXT: [[Y1:%.*]] = call i32 @llvm.read_register.i32(metadata [[META0]]) #[[ATTR1]]
; CHECK-NEXT: br label [[END]]
; CHECK: end:
-; CHECK-NEXT: [[Y2:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[X1]], [[IF]] ]
+; CHECK-NEXT: [[Y2:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[Y1]], [[IF]] ]
; CHECK-NEXT: [[RET:%.*]] = add i32 [[X1]], [[Y2]]
; CHECK-NEXT: ret i32 [[RET]]
;
Index: llvm/lib/Transforms/Scalar/EarlyCSE.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/EarlyCSE.cpp
+++ llvm/lib/Transforms/Scalar/EarlyCSE.cpp
@@ -140,7 +140,8 @@
// correctness. However, it may block many other correct
// optimizations. Revert this one when we detect the memory
// accessing kind more precisely.
- !CI->getFunction()->isPresplitCoroutine();
+ !CI->getFunction()->isPresplitCoroutine() &&
+ !CI->isConvergent();
}
return isa<CastInst>(Inst) || isa<UnaryOperator>(Inst) ||
isa<BinaryOperator>(Inst) || isa<GetElementPtrInst>(Inst) ||
@@ -495,7 +496,8 @@
// correctness. However, it may block many other correct
// optimizations. Revert this one when we detect the memory
// accessing kind more precisely.
- CI->getFunction()->isPresplitCoroutine())
+ CI->getFunction()->isPresplitCoroutine() ||
+ CI->isConvergent())
return false;
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153151.532189.patch
Type: text/x-patch
Size: 1903 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230616/fc7e823e/attachment.bin>
More information about the llvm-commits
mailing list