[PATCH] D87976: Support the division-by-constant strength reduction for more integer types

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 11:21:16 PDT 2020


efriedma added a comment.

> In either of these two instances the strength-reduced operation has a better throughput than the best case of a native (although most likely micro-coded) division instruction. I strongly doubt a software implementation of division could do at all better than such a native instruction. Although I could see scales tipping for targets where there are no native multiplication instructions.

There are 2 issues here that x86 in particular avoids:

1. Some targets don't really have a multiplier, like certain RISC-V variants.  Or some targets have a multiply instruction that's hard to use here, like Cortex-M0.
2. The libcall is doing a ton of extra work to produce the result of an NxN->N multiply.  We don't have the libcall variant we want here.

> However, it does manage to generate any assembly at all. LLVM could not do it before because there are no libcalls it knows about >128bit. So that's already somewhat of an improvement.

If we really cared about this, we could emit a general-purpose implementation inline.  We don't do this because that isn't what anyone wants anyway.



================
Comment at: llvm/test/CodeGen/AArch64/urem-seteq-nonzero.ll:207
+; CHECK-NEXT:    cset w0, eq
 ; CHECK-NEXT:    ret
   %urem = urem i16 %X, 3
----------------
Any idea what's going on here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87976



More information about the llvm-commits mailing list