[RISCV] Lower inline asm m with offset to register+imm.
authorMikhail R. Gadelha <mikhail@igalia.com>
Fri, 31 Mar 2023 15:58:58 +0000 (12:58 -0300)
committerMikhail R. Gadelha <mikhail@igalia.com>
Fri, 31 Mar 2023 16:20:13 +0000 (13:20 -0300)
commit6217f472a6357426ebba531c5cc24887e59d3285
tree55fab4f7ce058a27edecaa96963be62c612fd16c
parent0b0704996970f5c425c54c1ba590674fc5dc43ce
[RISCV] Lower inline asm m with offset to register+imm.

As part of D145584, we noticed that llvm was generating suboptimal code
for constraint m when the operand can be be lowered to reg+imm form: it
was being selected as a single register rather than register+imm. This
caused an unnecessary 'addi' to be gen for each m constraint.

This patch changes llvm to select register+imm. This might generate code
that cannot be assembled, but matches gcc's behavior.

Reviewed By: craig.topper, kito-cheng

Differential Revision: https://reviews.llvm.org/D146245
llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
llvm/test/CodeGen/RISCV/inline-asm.ll