[PATCH] D37467: Add a new pass to speculate around PHI nodes with constant (integer) operands when profitable.

Chandler Carruth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 20 14:22:52 PST 2017


chandlerc added a comment.

In https://reviews.llvm.org/D37467#900122, @MatzeB wrote:

> Without having read the code yet:
>
> > We could in theory make it part of the codegen pass
> >  pipeline, but there doesn't really seem to be a good reason for that --
> >  it isn't "lowering" in any sense and only relies on pretty standard cost
> >  model based TTI queries, so it seems to fit well with the "optimization"
> >  pipeline model.
>
> This does sound like a CodeGen pass to me! Not all of CodeGen is lowering, we do have optimization passes there too. And the fact that TTI is used is another indicator that this is a machine specific pass. This being part of CodeGen would also allow targets to not add the pass to the pipeline if it doesn't help them.


I responded to Mattias in person about this, but wanted to add it here.

Essentially, we have a nice "optimization" phase of the main pass pipeline now where there is no ambiguity about this being a non-canonicalization transform.

It would be pretty hard to implement this today as an MI pass because of how folding of addressing modes and such happens currently. I don't really know how to do this at all.

We could make this a CodeGen IR pass, but there doesn't seem to be any reason to do so. The API needed for this is already in TTI and seems to fit the TTI model very well: a completely generic cost model.

So it seems fine to add it here, and if we ever want to sink it to a CodeGen IR pass, we can, but I don't see any reason to speculatively do that. (Queue the puns...)


https://reviews.llvm.org/D37467





More information about the llvm-commits mailing list