[PATCH] D84181: [NFC][GVN] Rewrite IsValueFullyAvailableInBlock()

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 20 09:20:26 PDT 2020


lebedev.ri created this revision.
lebedev.ri added reviewers: fhahn, nikic, mkazantsev, lattner.
lebedev.ri added a project: LLVM.
Herald added a subscriber: hiraditya.

While this doesn't appear to help with the perf issue being exposed by D84108 <https://reviews.llvm.org/D84108>,
the function as-is is very weird, convoluted, and what's worse, recursive.

There was no need for `SpeculativelyAvaliableAndUsedForSpeculation`,
tri-state choice is enough. We don't even ever check for that state.

The basic idea here is that we need to perform a depth-first traversal of the 
predecessors of the basic block in question, either finding a preexisting
state for the block in a map, or inserting a "placeholder" `SpeculativelyAvaliable`,

If we encounter an `Unavaliable` block, then we need to give up search,
and back-propagate the `Unavaliable` state to the each successor of said block,
more specifically to the each `SpeculativelyAvaliable` we've just created.

However, if we have traversed entirety of the predecessors and have not
encountered an `Unavaliable` block, then it must mean the value is fully available.
We could update each inserted `SpeculativelyAvaliable` into a `Avaliable`,
but we don't need to, as assertion excersizes, because we can assume that if
we see an `SpeculativelyAvaliable` entry, it is actually `Avaliable`,
because during the time we've produced it, if we would have found that it
has an `Unavaliable` predecessor, we would have updated it's successors,
including this block, into `Unavaliable`

The perf story is confusing here.
This is http://llvm-compile-time-tracker.com/compare.php?from=04b729d076af038c2a86b62c0c150e340bf7a622&to=4930b199438b2e44d3c9639e12f7da62a8faf7be&stat=instructions
Instructions stat regressed. But i'm not sure instructions is *really* the right metric here,
Because task-clock stat really improved, by `-1.5% .. -5%` all across the board.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84181

Files:
  llvm/lib/Transforms/Scalar/GVN.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84181.279268.patch
Type: text/x-patch
Size: 8487 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200720/96711514/attachment.bin>


More information about the llvm-commits mailing list