On 12/23/23 16:37, Roger Sayle wrote:

One of the cool features of the H8 backend is its use of tables to select
optimal shift implementations for different CPU variants.  This patch
borrows (plagiarizes) that idiom for SImode left shifts in the ARC backend
(for CPUs without a barrel-shifter).  This provides a convenient mechanism
for both selecting the best implementation strategy (for speed vs. size),
and providing accurate rtx_costs [without duplicating a lot of logic].
Left shift RTX costs are especially important for use in synth_mult.

An example improvement is:

int foo(int x) { return 32768*x; }

which is now generated with -O2 -mcpu=em -mswap as:

foo:    bmsk_s  r0,r0,16
         swap    r0,r0
         j_s.d   [blink]
         ror     r0,r0

where previously the ARC backend would generate a loop:

foo:    mov     lp_count,15
         lp      2f
         add     r0,r0,r0
         nop
2:      # end single insn loop
         j_s     [blink]


Tested with a cross-compiler to arc-linux hosted on x86_64,
with no new (compile-only) regressions from make -k check.
Ok for mainline if this passes Claudiu's and/or Jeff's testing?
[Thanks again to Jeff for finding the typo in my last ARC patch]
So just an FYI. There's no upstream gdbsim for the arc, so my tester just uses a dummy simulator which says everything passes.

So I could include your patch to test that the compiler doesn't ICE, produces results that will assemble/link, but it won't test the correctness of the resulting code.

Jeff

Reply via email to