[PATCH] Better __ashlDI3, __ashrDI3 and __lshrDI3 functions, plus fixed __bswapsi2 function
Tue Nov 10 18:32:52 GMT 2020
On 11/10/20 11:09 AM, Jakub Jelinek via Gcc-patches wrote:
> On Tue, Nov 10, 2020 at 06:59:30PM +0100, Stefan Kanthak via Gcc-patches wrote:
>> The implementation of the __ashlDI3(), __ashrDI3() and __lshrDI3() functions
>> is rather bad, it yields bad machine code at least on i386 and AMD64.
>> Since GCC knows how to shift integers twice the register size these functions
>> can be written as one-liners.
> This looks wrong. If gcc knows how to do that inline, it will not call the
> out of line function at all. The functions are there for the cases where
> gcc can't do that.
> So, your patch will shorten the routines on targets where those are never
> called, and completely break them on any other (resulting in infinite
> recursion there).
There's a way to test that. It's possible the expanders know how to
handle these cases now. I'd be surprised (as I was with the [u]cmpdi2),
but it's possible. I can throw it into the tester which will spin all
those pesky embedded targets. If we get infinite recursion it should
show up quite clearly.
Of course, if the expanders now handle all the cases, then these
routines in libgcc2 are dead code and this is a fairly pointless exercise.
More information about the Gcc-patches