[all-commits] [llvm/llvm-project] 8ff483: [LSR] Preserve LCSSA when rewriting instruction wi...

Dmitry Makogon via All-commits all-commits at lists.llvm.org
Thu Mar 30 00:49:41 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8ff4832679e1ff2d2a1cfaa45bb5cb995b0685a1
      https://github.com/llvm/llvm-project/commit/8ff4832679e1ff2d2a1cfaa45bb5cb995b0685a1
  Author: Dmitry Makogon <d.makogon at g.nsu.ru>
  Date:   2023-03-30 (Thu, 30 Mar 2023)

  Changed paths:
    M llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    M llvm/test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll
    M llvm/test/Transforms/LoopStrengthReduce/AMDGPU/lsr-invalid-ptr-extend.ll
    M llvm/test/Transforms/LoopStrengthReduce/X86/2011-11-29-postincphi.ll
    M llvm/test/Transforms/LoopStrengthReduce/X86/expander-crashes.ll
    M llvm/test/Transforms/LoopStrengthReduce/X86/expander-reused-value-insert-point.ll
    M llvm/test/Transforms/LoopStrengthReduce/X86/sibling-loops.ll
    M llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting.ll
    M llvm/test/Transforms/LoopStrengthReduce/depth-limit-overrun.ll
    M llvm/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll
    M llvm/test/Transforms/LoopStrengthReduce/preserve-lcssa.ll
    M llvm/test/Transforms/LoopStrengthReduce/uglygep.ll

  Log Message:
  -----------
  [LSR] Preserve LCSSA when rewriting instruction with PHI user

Fixes https://github.com/llvm/llvm-project/issues/61182.

LoopStrengthReduce may sometimes break LCSSA form when applying a rewrite
for an instruction used in a PHI.
It happens if:
 - The PHI is in a loop exit block,
 - The edge from the corresponding exiting block to that exit is critical,
 - The PHI has at least two inputs coming from loop blocks,
 - and the rewritten instruction is inserted in the loop.

In such case we split the critical edge and then replace PHI inputs
with the rewritten instruction. However ExitBlock is no longer
a loop exit, so LCSSA form is broken.

This patch fixes it by collecting all inserted instructions for PHIs
whose parent block is not a loop exit and then forming LCSSA for them.

Differential Revision: https://reviews.llvm.org/D146811




More information about the All-commits mailing list