[PATCH] D118216: [RISCV] eliminate rematerialization of array's base address

Jessica Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 8 10:31:16 PST 2022


jrtc27 added a comment.

In D118216#3305287 <https://reviews.llvm.org/D118216#3305287>, @craig.topper wrote:

> In D118216#3305266 <https://reviews.llvm.org/D118216#3305266>, @jrtc27 wrote:
>
>> This seems conceptually wrong to me. isAsCheapAsAMove is meant to model how expensive an instruction is to execute, but how you compute the immediate it uses has zero bearing on that. `lui rd, 0x123` and `lui rd, %hi(sym)` if `%hi(sym)` happens to be 0x123 are completely indistinguishable from the perspective of the processor. To me this screams of something elsewhere getting cost modelling wrong.
>
> Maybe the heuristic #1 should ignore the isCheapAsMove if the instruction isTriviallyRematerializable?

So the problem is that LUI _is_ current marked as cheap as a move, since we set isAsCheapAsAMove to 1 on the TableGen record, and the default case falls back on that value. What this patch does is override that and make LUIs that are part of address computations _not_ as cheap as a move.


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

https://reviews.llvm.org/D118216



More information about the llvm-commits mailing list