diff --git a/gcc/config/stormy16/stormy16.cc b/gcc/config/stormy16/stormy16.cc index 1ed619a289688..cf2f807def25a 100644 --- a/gcc/config/stormy16/stormy16.cc +++ b/gcc/config/stormy16/stormy16.cc @@ -2105,6 +2105,29 @@ xstormy16_output_shift (machine_mode mode, enum rtx_code code, return r; } + /* For shifts of size 2, we can use two shifts of size 1. */ + if (size == 2) + { + switch (code) + { + case ASHIFT: + sprintf (r, "shl %s,#1 | rlc %s,#1 | shl %s,#1 | rlc %s,#1", + r0, r1, r0, r1); + break; + case ASHIFTRT: + sprintf (r, "asr %s,#1 | rrc %s,#1 | asr %s,#1 | rrc %s,#1", + r1, r0, r1, r0); + break; + case LSHIFTRT: + sprintf (r, "shr %s,#1 | rrc %s,#1 | shr %s,#1 | rrc %s,#1", + r1, r0, r1, r0); + break; + default: + gcc_unreachable (); + } + return r; + } + /* For large shifts, there are easy special cases. */ if (size == 16) { diff --git a/gcc/testsuite/gcc.target/xstormy16/shiftsi.c b/gcc/testsuite/gcc.target/xstormy16/shiftsi.c new file mode 100644 index 0000000000000..42bbca795feaa --- /dev/null +++ b/gcc/testsuite/gcc.target/xstormy16/shiftsi.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +unsigned long ashift_1(unsigned long x) { return x << 1; } +unsigned long ashift_2(unsigned long x) { return x << 2; } +unsigned long lshiftrt_1(unsigned long x) { return x >> 1; } +unsigned long lshiftrt_2(unsigned long x) { return x >> 2; } +long ashiftrt_1(long x) { return x >> 1; } +long ashiftrt_2(long x) { return x >> 2; } + +/* { dg-final { scan-assembler-not "mov " } } */ +/* { dg-final { scan-assembler-not "or " } } */