[all-commits] [llvm/llvm-project] b6320e: Do actual DCE in LoopUnroll (try 3)

Philip Reames via All-commits all-commits at lists.llvm.org
Mon May 17 14:51:03 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b6320eeb8622f05e4a5d4c7f5420523357490fca
      https://github.com/llvm/llvm-project/commit/b6320eeb8622f05e4a5d4c7f5420523357490fca
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2021-05-17 (Mon, 17 May 2021)

  Changed paths:
    M llvm/lib/Transforms/Utils/LoopUnroll.cpp
    M llvm/test/Transforms/LoopUnroll/AArch64/full-unroll-trip-count-upper-bound.ll
    A llvm/test/Transforms/LoopUnroll/dce.ll
    M llvm/test/Transforms/LoopUnroll/full-unroll-invariant.ll
    M llvm/test/Transforms/LoopUnroll/nonlatchcondbr.ll
    M llvm/test/Transforms/LoopUnroll/optsize-loop-size.ll
    M llvm/test/Transforms/LoopUnroll/pr45939-peel-count-and-complete-unroll.ll
    M llvm/test/Transforms/LoopUnroll/scevunroll.ll
    M llvm/test/Transforms/LoopUnroll/unroll-header-exiting-with-phis.ll
    M llvm/test/Transforms/LoopUnroll/unroll-unconditional-latch.ll
    M llvm/test/Transforms/LoopUnrollAndJam/unroll-and-jam.ll

  Log Message:
  -----------
  Do actual DCE in LoopUnroll (try 3)

Recommitting after fixing a bug found post commit.  Amusingly, try 1 had been correct, and by reverting to incorporate last minute review feedback, I introduce the bug.  Oops.  :)

The problem was that recursively deleting an instruction can delete instructions beyond the current iterator (via a dead phi), thus invalidating iteration.  Test case added in LoopUnroll/dce.ll to cover this case.

LoopUnroll does a limited DCE pass after unrolling, but if you have a chain of dead instructions, it only deletes the last one. Improve the code to recursively delete all trivially dead instructions.

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




More information about the All-commits mailing list