This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Teach merge conditional stores to handle cases where the PostBB has more than 2 predecessors by inserting a new block for the store.
ClosedPublic

Authored by craig.topper on Nov 7 2017, 1:52 PM.

Details

Summary

Currently merge conditional stores can't handle cases where PostBB (the block we need to move the store to) has more than 2 predecessors.

This patch removes that restriction by creating a new block with only the 2 predecessors we care about and an unconditional branch to the original block. This provides a place to put the store.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Nov 7 2017, 1:52 PM
efriedma edited edge metadata.Nov 27 2017, 1:59 PM

Do you know how much impact this has, in the sense of making this transform trigger more often in benchmarks?

lib/Transforms/Utils/SimplifyCFG.cpp
2956 ↗(On Diff #121973)

You might want to explicitly note what is known about the terminators of QTB/QFB here; pred_begin can return a block multiple times in cases where a terminator contains multiple uses of a successor. (I don't think you can hit that case here, but it took me a few minutes to convince myself.)

This didn't affect the resulting binary of most of the benchmarks in the set we normally look at. Out of the few that did change, one showed a perf improvement. The rest looked to be in the noise.

Add additional comment

efriedma accepted this revision.Apr 3 2018, 5:21 PM

LGTM

I completely forgot about this, sorry about the delay.

This revision is now accepted and ready to land.Apr 3 2018, 5:21 PM
This revision was automatically updated to reflect the committed changes.