Recommit "[TargetLowering][RISCV][X86] Support even divisors in expandDIVREMByConstant."
authorCraig Topper <craig.topper@sifive.com>
Mon, 24 Oct 2022 14:16:24 +0000 (07:16 -0700)
committerCraig Topper <craig.topper@sifive.com>
Mon, 24 Oct 2022 17:08:50 +0000 (10:08 -0700)
commit1fa8fd4c33cbb6bcf473c36f179640e2a8b4dd32
tree4a2f042cfb09d8674ffe4242c06528537013031b
parentda4baa9ebe76c6ed405424a80b582473904a185e
Recommit "[TargetLowering][RISCV][X86] Support even divisors in expandDIVREMByConstant."

This reverts commit 65aaecca8842dec30d03734a7fe8ce33c5afec81.

There was an ordering problem in the calculation of the partial
remainder.

Original commit message:

If the divisor is even, we can first shift the dividend and divisor
right by the number of trailing zeros. Now the divisor is odd and we
can do the original algorithm to calculate a remainder. Then we shift
that remainder left by the number of trailing zeros and add the bits
that were shifted out of the dividend.

Differential Revision: https://reviews.llvm.org/D135541
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/RISCV/split-udiv-by-constant.ll
llvm/test/CodeGen/RISCV/split-urem-by-constant.ll
llvm/test/CodeGen/X86/divide-by-constant.ll
llvm/test/CodeGen/X86/divmod128.ll