[PATCH] D100780: [Passes] Add extra LoopSimplifyCFG run after IndVarSimplify (WIP).

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 19 11:38:22 PDT 2021


fhahn created this revision.
Herald added subscribers: pengfei, hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

IndVarSimplify may simplify branch conditions for blocks in loops, but
does not simplify conditional to unconditional branches.

This can pessimize later passes, like loop-delete, which check for
certain conditions across all blocks in a loop. This results in cases
where we fail to delete or vectorize loops, e.g. because they contain
dynamically dead blocks with calls with side effects.

See PR28969.

Compile-time impact:

- O3 <https://reviews.llvm.org/owners/package/3/> geomean: +0.10%
- O3 <https://reviews.llvm.org/owners/package/3/> ThinLTO: +0.16%
- O3 <https://reviews.llvm.org/owners/package/3/> LTO : +0.21%

http://llvm-compile-time-tracker.com/compare.php?from=ddcdeae358685f941c3520e01b0a8e86e3aca04b&to=15bf70b47626fa7baf2c671fe8753bee178f98cf&stat=instructions

This shakes up quite a few things, with quite a few stats changes across
MultiSource/SPEC2000/SPEC2006 on X86 with -flto -O3

e.g.

  Same hash: 203 (filtered out)
  Remaining: 34
  Metric: loop-vectorize.LoopsVectorized
  
  Program                                        base   patch  diff
   test-suite...6/464.h264ref/464.h264ref.test   156.00 159.00  1.9%
   test-suite...marks/7zip/7zip-benchmark.test   336.00 341.00  1.5%
   test-suite...T2006/445.gobmk/445.gobmk.test    90.00  90.00  0.0%
   test-suite...ProxyApps-C++/CLAMR/CLAMR.test   196.00 196.00  0.0%
  
   Same hash: 203 (filtered out)
  Remaining: 34
  Metric: scalar-evolution.NumTripCountsComputed
  
  Program                                        base     patch    diff
   test-suite...nch/fourinarow/fourinarow.test    64.00    81.00   26.6%
   test-suite...6/464.h264ref/464.h264ref.test   5330.00  5969.00  12.0%
   test-suite...cations/hexxagon/hexxagon.test    77.00    84.00    9.1%
   test-suite...ications/JM/lencod/lencod.test   5227.00  5660.00   8.3%
   test-suite...ications/JM/ldecod/ldecod.test   2396.00  2592.00   8.2%
   test-suite.../Prolangs-C/loader/loader.test    13.00    14.00    7.7%
   test-suite...nal/skidmarks10/skidmarks.test   933.00   993.00    6.4%
   test-suite...lications/viterbi/viterbi.test    49.00    52.00    6.1%
   test-suite...nsumer-lame/consumer-lame.test   1715.00  1779.00   3.7%
   test-suite...T2006/445.gobmk/445.gobmk.test   2611.00  2687.00   2.9%
   test-suite...marks/7zip/7zip-benchmark.test   4512.00  4642.00   2.9%
   test-suite...CI_Purple/SMG2000/smg2000.test   2007.00  2057.00   2.5%
   test-suite...CFP2000/188.ammp/188.ammp.test   741.00   759.00    2.4%
   test-suite...006/453.povray/453.povray.test   2504.00  2560.00   2.2%
   test-suite...:: External/Povray/povray.test   2583.00  2633.00   1.9%
   test-suite.../CINT2000/176.gcc/176.gcc.test   2602.00  2650.00   1.8%
   test-suite...abench/jpeg/jpeg-6a/cjpeg.test   1307.00  1326.00   1.5%
   test-suite...nsumer-jpeg/consumer-jpeg.test   1332.00  1351.00   1.4%
   test-suite...TimberWolfMC/timberwolfmc.test   1283.00  1299.00   1.2%
   test-suite...006/447.dealII/447.dealII.test   22333.00 22579.00  1.1%
   test-suite...T2006/456.hmmer/456.hmmer.test   1671.00  1688.00   1.0%
   test-suite...ternal/HMMER/hmmcalibrate.test   1672.00  1689.00   1.0%
   test-suite...peg2/mpeg2dec/mpeg2decode.test   497.00   502.00    1.0%


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100780

Files:
  llvm/lib/Passes/PassBuilder.cpp


Index: llvm/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -582,6 +582,7 @@
 
   LPM2.addPass(LoopIdiomRecognizePass());
   LPM2.addPass(IndVarSimplifyPass());
+  LPM2.addPass(LoopSimplifyCFGPass());
 
   for (auto &C : LateLoopOptimizationsEPCallbacks)
     C(LPM2, Level);
@@ -757,6 +758,7 @@
                              EnableO3NonTrivialUnswitching));
   LPM2.addPass(LoopIdiomRecognizePass());
   LPM2.addPass(IndVarSimplifyPass());
+  LPM2.addPass(LoopSimplifyCFGPass());
 
   for (auto &C : LateLoopOptimizationsEPCallbacks)
     C(LPM2, Level);
@@ -1790,6 +1792,7 @@
 
   LoopPassManager LPM(DebugLogging);
   LPM.addPass(IndVarSimplifyPass());
+  LPM.addPass(LoopSimplifyCFGPass());
   LPM.addPass(LoopDeletionPass());
   // FIXME: Add loop interchange.
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100780.338580.patch
Type: text/x-patch
Size: 890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210419/103538de/attachment.bin>


More information about the llvm-commits mailing list