[PATCH] D119916: Add a machine function pass to convert binop(phi(constants), v) to phi(binop)

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 16 12:51:13 PST 2022


Carrot added a comment.

In D119916#3325471 <https://reviews.llvm.org/D119916#3325471>, @lebedev.ri wrote:

> I suppose this is the right place for this transformation, rather than in middle-end.
> Is this the same transform as D117110 <https://reviews.llvm.org/D117110>? Some enhancements are missing there, but do we need both?

D117110 <https://reviews.llvm.org/D117110> requires two phis, it works on code binop(phi1, phi2).
This patch covers more cases, it works on instructions binop(phi, v).

I think D117110 <https://reviews.llvm.org/D117110> is still required for reasons:

- Earlier transformation can also benefit other optimizations. For example in test case fold-phi-of-binary-op.ll of D115914 <https://reviews.llvm.org/D115914>, if the or(phi, phi) can be optimized in the mid end, tailcall can be generated by SelectionDAG. It we do the transformation in back end, we will miss the tailcall chance.
- D117110 <https://reviews.llvm.org/D117110> works for all targets. This patch needs a target implementation of canFoldImmediate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119916



More information about the llvm-commits mailing list