[PATCH] D36504: [CodeGenPrepare][WIP] Convert uncond. branch to return into a return to help with shrink-wrapping

Sean Fertile via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 2 10:41:36 PDT 2017


sfertile added a comment.

In https://reviews.llvm.org/D36504#913949, @kparzysz wrote:

>   CodeGenPrepare is not the place for this.


Thanks for the feedback. Can you elaborate a bit more on why we wouldn't want to do this in CodeGenPrepare? Is the issue that we are **always** duplicating the return right now? If thats the problem then we can try to come-up with situations where it may be profitable to duplicate the return and only do so under those circumstances.  Also shrink-wrapping isn't the only thing helped by this. This also addresses an issue where we miss tail-call opportunities because the result of the call feeds a PHI which feeds the return instruction.  By duplicating the return into the predecessor and removing the PHI we are able to tail call. In this case we would have to do the transformation here since we decide whether to tail-call or not during the SDag lowering, which comes next and only has access to a single basic block at a time.

In https://reviews.llvm.org/D36504#913949, @kparzysz wrote:

> Then perhaps shrink-wrapping should be extended to be able to add blocks.


I don't know enough about shrink wrapping to know if that is feasible or not. It doesn't seem practical to me, but maybe Francis or Quentin can comment?


Repository:
  rL LLVM

https://reviews.llvm.org/D36504





More information about the llvm-commits mailing list