[PATCH] D143898: [CodeGenPrepare] Relax conditions for folding addressing mode into loads/stores

Momchil Velikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 09:48:38 PDT 2023


chill added a comment.

In D143898#4303461 <https://reviews.llvm.org/D143898#4303461>, @efriedma wrote:

> For constructs like the given testcase, you don't need to reason about whether it's profitable to fold into a call; cloning a GEP into both sides of an if-else doesn't actually increase execution time, so it's obviously profitable even if you can only fold it on one side of the if-else.  Can you add some examples that actually require predicting whether the GEP is as cheap as a mov, and the argument is passed in a register?

These test cases are constructed just to have the addressing computation and its users in separate basic blocks.
In our motivating examples, we have the addressing computation as loop invariant and its users inside a loop body, so
just sinking copies might increase run time.

I have added such test cases in https://reviews.llvm.org/D152828  : `sink-and-fold.ll`, functions `f4` and `f5`.


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

https://reviews.llvm.org/D143898



More information about the llvm-commits mailing list