On 4/22/23 10:43, Roger Sayle wrote:

Currently on xstormy16 SImode shifts by a single bit require two
instructions, and shifts by other non-zero integer immediate constants
require five instructions.  This patch implements the obvious optimization
that shifts by two bits can be done in four instructions, by using two
single-bit sequences.

Hence, ashift_2 was previously generated as:
         mov r7,r2 | shl r2,#2 | shl r3,#2 | shr r7,#14 | or r3,r7
         ret
and with this patch we now generate:
         shl r2,#1 | rlc r3,#1 | shl r2,#1 | rlc r3,#1
         ret

This patch has been tested by building a cross-compiler to xstormy16-elf
on x86_64-pc-linux-gnu, and confirming that the new test case passes with
"make -k check-gcc".  Ok for mainline?


2023-04-22  Roger Sayle  <ro...@nextmovesoftware.com>

gcc/ChangeLog
         * config/stormy16/stormy16.cc (xstormy16_output_shift): Implement
         SImode shifts by two by performing a single bit SImode shift twice.

gcc/testsuite/ChangeLog
         * gcc.target/xstormy16/shiftsi.c: New test case.
OK.
jeff

Reply via email to