[PATCH] D93734: [LoopDeletion] Insert an early exit from dead path in loop

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 27 05:25:14 PDT 2021


jonpa updated this revision to Diff 375210.
jonpa added a comment.

I again saw a regression on omnetpp against gcc so I decided to revisit this patch as it previously handled that benchmar. In doing so I have updated/revisited with some more comments as well. It now only runs on the new pass manager.

It seems however that this time it was not the loop in PrintAddressTable that was the issue, so I still can't say what the omnetpp regression is about this time. However, I reran SPEC-17 and found that a few benchmarks seemed to improve just slighty (~1%). Statistics report that still ~1400 loops get optimized with this patch (~2400 edges redirected). So at least in theory, this patch might still be of interest, even if just to give hints on missed optimizations by other loop passes.

I checked if the extra work of finding Top/Bot regions and handling multiple exits where still worthwhile (compared to a very simple approach). I found that the Top/Bot search about doubled the effectiveness (relative just checking edges from Header to Latch), where the multiple exit loops were about 10% of the cases (I now made multiple-exit handling fall under an experimental option "-early-exit-extra".).

f510.parest_r seemed to improve ~1.5% on both z14 and z15, and I made a reduced test case for one of the files changed (sparsity_pattern.ii, picked randomly). I see three less BBs in the output and an outer loop removed.

  opt -mtriple=systemz-unknown -march=z14 -O3 ./tc_earlex.ll -debug-only=loop-delete
  
  Analyzing Loop for deletion: Loop at depth 1 containing: %bb5.preheader<header>,%bb8,%bb1.loopexit<latch><exiting>,%bb8.preheader,%bb1.loopexit.loopexit
      Loop at depth 2 containing: %bb8<header><latch><exiting>
  Loop is not invariant, cannot delete.
  Trying to insert early exits:
  Top region: bb5.preheader, bb8.preheader, 
  Bot region: bb1.loopexit, bb1.loopexit.loopexit, 
  Inserting early exit in bb5.preheader:
    br i1 %i7.not3, label %bb1.loopexit, label %bb8.preheader
    =>
    br i1 %i7.not3, label %bb9.loopexit, label %bb8.preheader

F19275083: tc_earlex.ll <https://reviews.llvm.org/F19275083>

Thoughts anyone? Maybe somebody would like to try the patch on some other platform?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93734/new/

https://reviews.llvm.org/D93734

Files:
  llvm/lib/Transforms/Scalar/LoopDeletion.cpp
  llvm/test/Transforms/LoopDeletion/early-exits.ll
  llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93734.375210.patch
Type: text/x-patch
Size: 22584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210927/ac9779da/attachment.bin>


More information about the llvm-commits mailing list