[all-commits] [llvm/llvm-project] 1e670d: [RISCV] Use DIVUW/REMUW/DIVW instructions for i8/i...
Craig Topper via All-commits
all-commits at lists.llvm.org
Tue Jul 13 10:34:24 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 1e670dc7d78427156c252317b3571576d465043f
https://github.com/llvm/llvm-project/commit/1e670dc7d78427156c252317b3571576d465043f
Author: Craig Topper <craig.topper at sifive.com>
Date: 2021-07-13 (Tue, 13 Jul 2021)
Changed paths:
M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
M llvm/test/CodeGen/RISCV/div.ll
M llvm/test/CodeGen/RISCV/rem.ll
Log Message:
-----------
[RISCV] Use DIVUW/REMUW/DIVW instructions for i8/i16/i32 udiv/urem/sdiv when LHS is constant.
We don't really have optimizations for division with a constant
LHS. If we don't use a W instruction we end up needing to sign
or zero extend the RHS to use the 64-bit instruction.
I had to sign_extend i32 constants on the LHS instead of using
any_extend which becomes zero_extend. If we don't do this, constants
that were originally negative become harder to materialize. I think
this problem exists for more of our W instruction cases. For example
(i32 (shl -1, X)), but we don't have lit tests. I'll work on that
as a follow up.
I also left a FIXME for enabling W instruction for RHS constants
under -Oz.
Reviewed By: luismarques
Differential Revision: https://reviews.llvm.org/D105769
More information about the All-commits
mailing list