[PATCH] D117045: [SimplifyCFG] Be more aggressive when sinking into unreachable-post-dominated block

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 11 12:05:16 PST 2022


lebedev.ri created this revision.
lebedev.ri added reviewers: rnk, nikic, efriedma.
lebedev.ri added a project: LLVM.
Herald added a subscriber: hiraditya.
lebedev.ri requested review of this revision.

I strongly believe we need some variant of this.

The main problem is e.g. that the glibc's assert has 4 parameters,
but the profitability check is only okay with one extra phi node,
so D116692 <https://reviews.llvm.org/D116692> doesn't even trigger on most of the expected cases.

While that restriction probably makes sense in normal code, if we
are about to run off of a cliff (into an `unreachable`), this
successor block is unlikely so the cost to setup these PHI nodes
should not be on the hotpath, and shouldn't matter performance-wise.

Likewise, we don't sink if there are unconditional predecessors
UNLESS we'd sink at least one non-speculatable instruction,
which is a performance workaround, but if we are about to run into
`unreachable`, it shouldn't matter.

One open question is whether to only allow simple control flow
that directly unconditionally leads to unreachable,
or instead check that all the function terminator blocks
that post-dominate the block into which we are sinking
are `unreachable` (i.e. allow loops).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117045

Files:
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/Transforms/SimplifyCFG/X86/sink-common-code-into-unreachable.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117045.399028.patch
Type: text/x-patch
Size: 12201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220111/7f67c1e3/attachment.bin>


More information about the llvm-commits mailing list