[PATCH] D82660: [RISCV] Optimize multiplication by specific immediates

Sam Elliott via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 2 04:15:42 PDT 2020


lenary added a comment.

I'm happy with this optimisation where this patch removes multiply libcalls.

Where the target has a the m extension, and especially for 64-bit multiplies on rv32im, I'm not sure this is an optimisation.

I think that, for the moment, we should add a guard to the hook to avoid this transformation where we do have mul instructions:

  if (Subtarget.hasStdExtM())
    return false;

What do you think?



================
Comment at: llvm/test/CodeGen/RISCV/mul.ll:551-562
+; RV32IM-NEXT:    slli a2, a0, 6
+; RV32IM-NEXT:    add a3, a2, a0
+; RV32IM-NEXT:    sltu a2, a3, a2
+; RV32IM-NEXT:    srli a0, a0, 26
+; RV32IM-NEXT:    slli a4, a1, 6
+; RV32IM-NEXT:    or a0, a4, a0
+; RV32IM-NEXT:    add a0, a0, a1
----------------
I think this is a pessimisation, though I realise that depends on how slow the 32-bit multiplier is compared to add/shift.


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

https://reviews.llvm.org/D82660





More information about the llvm-commits mailing list