[PATCH] D88293: [ControlDependentDCE] Add Control Dependent DCE pass

Masaki Arai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 04:59:05 PDT 2020


masakiarai created this revision.
masakiarai added reviewers: brzycki, dexonsmith, dmgreen, jfb, john.brawn, llvm-commits, NutshellySima.
Herald added subscribers: steven_wu, hiraditya, mgorny.
Herald added a project: LLVM.
masakiarai requested review of this revision.

Add Control Dependent DCE pass.

Add Control Dependent DCE pass.
This pass performs 'control dependent DCE', which converts a conditional
branch of BB into an unconditional branch if possible, when the basic block
BBa dominates BB and both basic blocks have conditional branches under the
same condition.

BBa:

  %cmp = ...
  br i1 %cmp, label %LA1, label %LA2

...

BB:

  ...
  br i1 %cmp, label %LD1, label %LD2

The condition to apply this optimization is that the predecessors of BB is
divided into the set S1 coming from LA1 and the set S2 coming from LA2.
If S1(or S2) is empty, it rewrites the conditional branch to an
unconditional branch to LD2(or LD1).
If both S1 and S2 are not empty and BB can be duplicated, BB is duplicated
for S2, and each conditional branches in BB and the duplicated BB are
converted into unconditional branches for LD1 and LD2, respectively.

NOTE: This patch is a reconstruction of the following patch.



  [Jump Threading] Convert conditional branches into unconditional branches using GVN results
  https://reviews.llvm.org/D57953

This patch duplicates and holds the variables and functions related to TryThreadEdge in JumpThreading pass.
Therefore, it is necessary to create a patch that makes these duplicates into a library before committing this patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88293

Files:
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Transforms/Scalar.h
  llvm/include/llvm/Transforms/Scalar/ControlDependentDCE.h
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/Scalar/CMakeLists.txt
  llvm/lib/Transforms/Scalar/ControlDependentDCE.cpp
  llvm/lib/Transforms/Scalar/Scalar.cpp
  llvm/test/Transforms/ControlDependentDCE/conditional-to-unconditional.ll
  llvm/test/Transforms/ControlDependentDCE/duplicate-conditional.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88293.294279.patch
Type: text/x-patch
Size: 63817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200925/fb820a57/attachment.bin>


More information about the llvm-commits mailing list