This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Simplify based on a dominating condition (looking past hammocks and diamonds).
AbandonedPublic

Authored by mcrosier on Aug 3 2017, 2:16 PM.

Details

Summary

This patch extends the support for simplifying the CFG based on a dominating condition. The search threshold is increased from 1 to 3. In turn, a new function is added to IR BasicBlock, getIDom(), that looks past hammocks and diamonds. I suspect this new function might be useful in other scenarios.

No correctness issues or compile-time regressions above noise for llvmts, SPEC2000, SPEC2006, SPEC2017. This results in a small code size reduction in some cases and hits about 1/3 of the SPEC benchmarks and a few tests from the llvmts.

Chad

Diff Detail

Event Timeline

mcrosier created this revision.Aug 3 2017, 2:16 PM
efriedma edited edge metadata.Aug 3 2017, 2:48 PM

We already have a couple other passes which can do optimize your testcase (JumpThreading and GVN); what do we gain from doing this analysis here specifically?

EarlyCSE should be able to do this as well, and PredicateInfo will build a form that makes this trivial for anything to do it, in linear time, without any limits necessary.
(By numbers, predicateinfo was the fastest analysis we had that walked the IR at the time it was committed, so ...)

mcrosier abandoned this revision.Aug 4 2017, 9:05 AM

Eli and Danny have (rightfully) convinced me this has little/no merit. However, this is a derivative of some other work I've been doing with the inline cost model and I think both of your inputs would be very valuable. Please see: http://lists.llvm.org/pipermail/llvm-dev/2017-August/116183.html

We already have a couple other passes which can do optimize your testcase (JumpThreading and GVN); what do we gain from doing this analysis here specifically?

Just to follow up on your question, Eli. I suspect the fact that SimplifyCFG runs more frequently than JT and GVN result in a few additional cases being captured (perhaps cases exposed after JT/GVN). However, I honestly haven't done the full investigation to get a definitive answer. Again, this is just derivative work and I'm not particularly set on getting this committed.