[TargetLowering] Teach BuildUDIV to take advantage of leading zeros in the dividend.
authorCraig Topper <craig.topper@sifive.com>
Thu, 29 Dec 2022 21:58:46 +0000 (13:58 -0800)
committerCraig Topper <craig.topper@sifive.com>
Thu, 29 Dec 2022 21:58:46 +0000 (13:58 -0800)
commit8abd70081f761738e82b37b2891b60ad034f3880
tree7b38dc2278dd740dd6cafa05632fb7ca5dc3e35f
parent1ec021467da65c06cd4aa24ce81898b0759bd16b
[TargetLowering] Teach BuildUDIV to take advantage of leading zeros in the dividend.

If the dividend has leading zeros, we can use them to reduce the
size of the multiplier and avoid the fixup cases.

This patch is for scalars only, but we might be able to do this
for vectors in a follow up.

Differential Revision: https://reviews.llvm.org/D140750
12 files changed:
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/AArch64/funnel-shift.ll
llvm/test/CodeGen/AArch64/urem-vector-lkk.ll
llvm/test/CodeGen/AMDGPU/fshr.ll
llvm/test/CodeGen/ARM/select-imm.ll
llvm/test/CodeGen/PowerPC/funnel-shift.ll
llvm/test/CodeGen/PowerPC/urem-vector-lkk.ll
llvm/test/CodeGen/RISCV/urem-vector-lkk.ll
llvm/test/CodeGen/X86/divide-by-constant.ll
llvm/test/CodeGen/X86/funnel-shift.ll
llvm/test/CodeGen/X86/pr38217.ll
llvm/unittests/Support/DivisionByConstantTest.cpp