https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54089

--- Comment #68 from Alexander Klepikov <klepikov.alex+bugs at gmail dot com> 
---
OK, I finished my patch. Let me remind you briefly, what it does.

First, it does not emit library call for ashrsi3 during expand pass. Instead it
emits intermediate 'collapsed' libcall insn which is expanded later at split1
pass.

Consecutive right arithmetic shifts can be catched at combine pass
and converted to 'collapsed' libcall insn.

Then 'collapsed' insn splits whether to short sequnce of individual right
shifts
or to __ashiftrt_r4_N library call during split1 pass.

Finally, loop move invariants only pass executed right after split1 pass
to hoist library addresses that potentially were emitted during split pass.

I ran GCC testsuite and there were 1 new failed test that actually turned out
to be an optimization, and 3 tests that failed on clean GCC and passed on
patched. I could not set up my environment to test all little endian exec
tests, so for those I don't have results. Also I successfully compiled (but not
linked due to not fully set environment) Linux kenel 6.1. My homemade
performance tests (I timed linux kernel build) showed a slowdown of less then
3%.

To reduce slowdown it would be good to run loop move invariants pass only in
functions that have expanded libcall, but to do so it is necessary to mark such
funcnion when emitting insn and I'm not so sure if insn knows about in what
function it is located.

Reply via email to