[PATCH] D50222: [CodeGen] [SelectionDAG] More efficient code for X % C == 0
Dmytro Shynkevych via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 7 08:25:05 PDT 2018
hermord updated this revision to Diff 159505.
hermord added a comment.
As pointed out by @lebedev.ri, tests were inadequate. Added new tests and stepped through existing ones, adding descriptions. This uncovered two more bugs, which were also fixed here (an extraneous `Q.lshrInPlace()` and division by D instead of D0). As far as I can see, the coverage now seems reasonable; please point out any cases I missed.
Regarding @majnemer's suggestion, my bad: I should have mentioned in the last update that this algorithm actually assumes that D is positive ("because d is odd and, as we are assuming, positive and not equal to 1..." [Hacker's Delight, p.227]). It probably can be adapted to the `D < 0` case with some tweaks, but it seems easier to just take the absolute value of `D` since this does not change the answer.
Repository:
rL LLVM
https://reviews.llvm.org/D50222
Files:
include/llvm/CodeGen/TargetLowering.h
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
lib/CodeGen/SelectionDAG/TargetLowering.cpp
test/CodeGen/Hexagon/swp-const-tc2.ll
test/CodeGen/X86/jump_sign.ll
test/CodeGen/X86/rem.ll
test/CodeGen/X86/vselect-avx.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50222.159505.patch
Type: text/x-patch
Size: 21713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180807/b40ee860/attachment.bin>
More information about the llvm-commits
mailing list