[llvm] f502683 - [MergeICmps] Relax sinking check

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 23 13:16:23 PDT 2021


Author: Nikita Popov
Date: 2021-07-23T22:16:11+02:00
New Revision: f502683750f4240c48a3e24bf023294e4a27929e

URL: https://github.com/llvm/llvm-project/commit/f502683750f4240c48a3e24bf023294e4a27929e
DIFF: https://github.com/llvm/llvm-project/commit/f502683750f4240c48a3e24bf023294e4a27929e.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/MergeICmps.cpp
    llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/MergeICmps.cpp b/llvm/lib/Transforms/Scalar/MergeICmps.cpp
index 283e9029571ab..3306f605ac7c7 100644
--- a/llvm/lib/Transforms/Scalar/MergeICmps.cpp
+++ b/llvm/lib/Transforms/Scalar/MergeICmps.cpp
@@ -248,9 +248,9 @@ class BCECmpBlock {
 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;

diff  --git a/llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll b/llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll
index cb911ebbf1255..0b9663f449803 100644
--- a/llvm/test/Transforms/MergeICmps/X86/split-block-does-work.ll
+++ b/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(


        


More information about the llvm-commits mailing list