[PATCH] D106591: [MergeICmps] Relax sinking check
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 22 13:28:02 PDT 2021
nikic created this revision.
nikic added a reviewer: courbet.
Herald added a subscriber: hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The check for sinking instructions past the load + cmp sequence currently checks for side-effects, which includes writing to memory and unwinding. However, I don't believe we care about sinking the instructions past an unwind (as they don't have any side-effects themselves).
Noticed this will reviewing uses of mayHaveSideEffect() for an upcoming change.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D106591
Files:
llvm/lib/Transforms/Scalar/MergeICmps.cpp
llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll
Index: llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll
===================================================================
--- llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll
+++ llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll
@@ -3,7 +3,7 @@
%S = type { i32, i32, i32, i32 }
-declare void @foo(...) nounwind readnone
+declare void @foo(...) readonly
; We can split %entry and create a memcmp(16 bytes).
define zeroext i1 @opeq1(
Index: llvm/lib/Transforms/Scalar/MergeICmps.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/MergeICmps.cpp
+++ llvm/lib/Transforms/Scalar/MergeICmps.cpp
@@ -248,9 +248,9 @@
bool BCECmpBlock::canSinkBCECmpInst(const Instruction *Inst,
DenseSet<Instruction *> &BlockInsts,
AliasAnalysis &AA) const {
- // If this instruction has side effects and its in middle of the BCE cmp block
- // instructions, then bail for now.
- if (Inst->mayHaveSideEffects()) {
+ // If this instruction may clobber the loads and is in middle of the BCE cmp
+ // block instructions, then bail for now.
+ if (Inst->mayWriteToMemory()) {
// Bail if this is not a simple load or store
if (!isSimpleLoadOrStore(Inst))
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106591.360950.patch
Type: text/x-patch
Size: 1335 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210722/293e85f4/attachment.bin>
More information about the llvm-commits
mailing list