Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f502683

Browse files
committed
[MergeICmps] Relax sinking check
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). Differential Revision: https://reviews.llvm.org/D106591
1 parent 18ce3d3 commit f502683

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

llvm/lib/Transforms/Scalar/MergeICmps.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ class BCECmpBlock {
248248
bool BCECmpBlock::canSinkBCECmpInst(const Instruction *Inst,
249249
DenseSet<Instruction *> &BlockInsts,
250250
AliasAnalysis &AA) const {
251-
// If this instruction has side effects and its in middle of the BCE cmp block
252-
// instructions, then bail for now.
253-
if (Inst->mayHaveSideEffects()) {
251+
// If this instruction may clobber the loads and is in middle of the BCE cmp
252+
// block instructions, then bail for now.
253+
if (Inst->mayWriteToMemory()) {
254254
// Bail if this is not a simple load or store
255255
if (!isSimpleLoadOrStore(Inst))
256256
return false;

llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
%S = type { i32, i32, i32, i32 }
55

6-
declare void @foo(...) nounwind readnone
6+
declare void @foo(...) readonly
77

88
; We can split %entry and create a memcmp(16 bytes).
99
define zeroext i1 @opeq1(

0 commit comments

Comments
 (0)