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.
Paths
| Differential D140750
[TargetLowering] Teach BuildUDIV to take advantage of leading zeros in the dividend. ClosedPublic Authored by craig.topper on Dec 28 2022, 9:14 PM.
Details Summary If the dividend has leading zeros, we can use them to reduce the This patch is for scalars only, but we might be able to do this
Diff Detail
Event TimelineComment Actions Can you update the exhaustive test too so we know this is actually correct?
Comment Actions LGTM, thank you!
This revision is now accepted and ready to land.Dec 29 2022, 12:25 PM This revision was landed with ongoing or failed builds.Dec 29 2022, 1:59 PM Closed by commit rG8abd70081f76: [TargetLowering] Teach BuildUDIV to take advantage of leading zeros in the… (authored by craig.topper). · Explain Why This revision was automatically updated to reflect the committed changes. Comment Actions If you're interested in this area, there's known improvements that haven't been implemented in LLVM, as pointed out by https://ridiculousfish.com/blog/posts/labor-of-division-episode-iii.html. See https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8258644/ for a more complete review of known techniques. Comment Actions This change broke the test divide-by-constant.ll in the M68k backend, the test may have to be updated.
Revision Contents
Diff 485631 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
|
clang-format not found in user’s local PATH; not linting file.