[PATCH] D82005: [InstCombine] Replace selects with Phis

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 17 21:35:48 PDT 2020


mkazantsev added a comment.

In D82005#2097999 <https://reviews.llvm.org/D82005#2097999>, @xbolva00 wrote:

> Recent work by @lebedev.ri went opposite way; phi -> select (mainly to exploit cmov on x86) so I am wondering why should we go this way..




In D82005#2098421 <https://reviews.llvm.org/D82005#2098421>, @xbolva00 wrote:

> I believe selects are better for other optimizations than phis


If you look at hte test `select_dominating_cond_and_sink` at `select.ll`, it shows an opportunity how we can reduce the amount of work on each execution path by sinking `TrueValue` and `FalseValue` to different branches. If we turn Phis into Selects, we will always have all those values on common path. If we think more of it, Phis open up great opportunities for jump threading and PRE while selects don't.

If the only reason of preferring selects over phis is their better lowering on some platforms, then there should be a backend transform that does it. >From optimizer's perspective, Phi has more advantages.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82005/new/

https://reviews.llvm.org/D82005





More information about the llvm-commits mailing list