[CORRECTION] [compiler-rt] _udivdi3(), _umoddi3(), _moddi3() and _divdi3() routines not properly "tuned"
Friedman, Eli via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 9 11:45:20 PST 2017
Please see
http://llvm.org/docs/DeveloperPolicy.html#making-and-submitting-a-patch
for directions to submit a patch.
General mailing list etiquette: If you're going to reply to an existing
thread, please use the "reply" button in your mail client so it's
threaded properly (even if you're replying to yourself). (Original
message:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20171106/500748.html
)
-Eli
On 11/9/2017 1:33 AM, Stefan Kanthak via llvm-commits wrote:
> Hi,
>
> replace the proposed fix #3 from my initial post with the following
> faster version:
>
>> Bug #3: such "highly tuned" routines should but come without large
>> ~~~~~~~ duplicate code sequences.
>>
>> In the 4 routines named in the subject, the code from label 1: to the
>> respective return is almost identical to the code preceeding label 1:;
>> the only difference is the initial subtraction and the insertion of
>> a leading 1 into the quotient.
>>
>> Fix #3: remove all lines between "jae 1f" (including the wrong
>> ~~~~~~~ comment which follows "jae 1f") and the label 1:, then
>> apply the following diff (yes, this adds one or two
>> instructions to the overall execution path, but should
>> typically cost no cycles, since they can execute in parallel).
> + pushl %edi
> + xorl %edi, %edi // MSB of quotient
> cmpl %ebx, %edx // to avoid overflowing the upcoming divide.
> + jb 0f
> - jae 1f
>
> 1: /* High word of a is greater than or equal to (b >> (1 + i)) on this branch */
>
> + movl $0x80000000, %edi // MSB of quotient
> subl %ebx, %edx // subtract bhi from ahi so that divide will not
> +
> +0: /* High word of a is smaller than (b >> (1 + i)) on this branch */
> +
> divl %ebx // overflow, and find q and r such that
> //
> // ahi:alo = (1:q)*bhi + r
> //
> // Note that q is a number in (31-i).(1+i)
> // fix point.
> - pushl %edi
> notl %ecx
> shrl %eax
> + orl %eax // insert proper MSB into quotient
> - orl $0x80000000, %eax
>
> regards
> Stefan Kanthak
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
More information about the llvm-commits
mailing list