[PATCH] D134023: [InstCombine] Try to sink instructions into nearest common dominator of its users

Dmitry Makogon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 16 01:12:56 PDT 2022


dmakogon created this revision.
dmakogon added reviewers: spatel, mkazantsev, reames, nikic, RKSimon.
Herald added subscribers: dmgreen, zzheng, hiraditya.
Herald added a project: All.
dmakogon requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

Currently InstCombine would only sink instruction if all its users are in the same block and this is block is a successor of the current one.
There are cases where the users are in different blocks but all these blocks are dominated by succesor of our block.
E.g.:

  %bb:
    %x = call i8* @foo()
    %is.null = icmp eq i8* %p, null
    br i1 %is.null, label %null, label %not.null
  
  not.null:
    call void @use(i8* %x)
    br i1 %c, label %not.null.2, label %exit
  
  not.null.2:
    call void @use(i8* %x)
    br label %exit

Here we could sink `%x` to `not.null` block.
This patch adjustes the InstCombine sinking mechanism so that it sinks instructions to the nearest common dominator of instruction users.


https://reviews.llvm.org/D134023

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/sink-into-ncd.ll
  llvm/test/Transforms/LoopUnroll/ARM/upperbound.ll
  llvm/test/Transforms/LoopUnroll/runtime-multiexit-heuristic.ll
  llvm/test/Transforms/LoopVectorize/AArch64/intrinsiccost.ll
  llvm/test/Transforms/LoopVectorize/ARM/mve-reductions.ll
  llvm/test/Transforms/LoopVectorize/X86/intrinsiccost.ll
  llvm/test/Transforms/LoopVectorize/induction.ll
  llvm/test/Transforms/LoopVectorize/interleaved-accesses.ll
  llvm/test/Transforms/LoopVectorize/loop-scalars.ll
  llvm/test/Transforms/LowerMatrixIntrinsics/multiply-fused-loops.ll
  llvm/test/Transforms/PhaseOrdering/AArch64/peel-multiple-unreachable-exits-for-vectorization.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134023.460668.patch
Type: text/x-patch
Size: 68400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220916/1c519576/attachment-0001.bin>


More information about the llvm-commits mailing list