[PATCH] D135125: [JumpThreading] Reverse the order of basic block iteration.

Usman Nadeem via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 3 21:08:31 PDT 2022


mnadeem created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
mnadeem requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch is a fix for a compile time issue I was seeing in
SPEC2017/cam4, reducing the monstrous compile time for
one file from 80+min to under 10sec.

The test changes seem reasonable, although I am not too sure
about the change in LazyValueAnalysis dump as I am not familiar with it.

Essentially the file I was compiling had many lines of fortran code of this
form: `arr(:ncol,:) = 0`. The 2d array dimensions in this case are statically
known.

When compiling with `flang-new` this is converted into a nested loop
with a store, and just before Jump Threading is run we have tens of
thousands of branches containing GEP + memsets and memcpys and each
threadable chain is very long as well.

With the current top down approach 90% of the time was spent
in renaming non-local uses of instructions in `updateSSA()`. Profiling
showed that about half that time was spent in the
`SSAUpdater::FindAvailableVals() --> FindExistingPHI()` call.  This is
because we were accumulating new PHIs as we kept on threading the
successors BBs.

I was not able to reduce a test case showing the high compile time but
the file is cldwat2m_macro.f90 and I compiled with O3 <https://reviews.llvm.org/owners/package/3/>.


https://reviews.llvm.org/D135125

Files:
  llvm/lib/Transforms/Scalar/JumpThreading.cpp
  llvm/test/Analysis/LazyValueAnalysis/lvi-after-jumpthreading.ll
  llvm/test/Transforms/CallSiteSplitting/callsite-split.ll
  llvm/test/Transforms/JumpThreading/PR33357-lvi-recursion.ll
  llvm/test/Transforms/JumpThreading/implied-cond.ll
  llvm/test/Transforms/JumpThreading/lvi-tristate.ll
  llvm/test/Transforms/JumpThreading/pr22086.ll
  llvm/test/Transforms/JumpThreading/pr36133.ll
  llvm/test/Transforms/JumpThreading/pr40992-indirectbr-folding.ll
  llvm/test/Transforms/JumpThreading/pr46857-callbr.ll
  llvm/test/Transforms/JumpThreading/select.ll
  llvm/test/Transforms/JumpThreading/static-profile.ll
  llvm/test/Transforms/JumpThreading/thread-loads.ll
  llvm/test/Transforms/JumpThreading/unreachable-loops.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135125.464882.patch
Type: text/x-patch
Size: 14107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221004/0ee9d328/attachment.bin>


More information about the llvm-commits mailing list