diff options
author | Jozef Lawrynowicz <jozef.l@mittosystems.com> | 2019-06-06 09:23:10 +0000 |
---|---|---|
committer | Jozef Lawrynowicz <jozefl@gcc.gnu.org> | 2019-06-06 09:23:10 +0000 |
commit | e445e4b4feb25facd3a61787c51c96eb3bda66f1 (patch) | |
tree | 59ac87cf7b187839129cbec50601df38d59e507f | |
parent | d1b2f85f78589a2bece2f874a6021ed746209697 (diff) | |
download | gcc-e445e4b4feb25facd3a61787c51c96eb3bda66f1.zip gcc-e445e4b4feb25facd3a61787c51c96eb3bda66f1.tar.gz gcc-e445e4b4feb25facd3a61787c51c96eb3bda66f1.tar.bz2 |
MSP430: Emulate 16-bit shifts with rotate insn when src operand is in memory
gcc/ChangeLog
2019-06-06 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* config/msp430/msp430.md (ashlhi3): Force shift src operand into a
register if it is in memory, so the shift can be emulated with a rotate
instruction.
(ashrhi3): Likewise.
(lshrhi3): Likewise.
gcc/testsuite/ChangeLog
2019-06-06 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* gcc.target/msp430/emulate-slli.c: New test.
* gcc.target/msp430/emulate-srai.c: New test.
* gcc.target/msp430/emulate-srli.c: New test.
From-SVN: r271993
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/config/msp430/msp430.md | 15 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/msp430/emulate-slli.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/msp430/emulate-srai.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/msp430/emulate-srli.c | 15 |
6 files changed, 68 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e6dd35a..7ddc942 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-06-06 Jozef Lawrynowicz <jozef.l@mittosystems.com> + + * config/msp430/msp430.md (ashlhi3): Force shift src operand into a + register if it is in memory, so the shift can be emulated with a rotate + instruction. + (ashrhi3): Likewise. + (lshrhi3): Likewise. + 2019-06-06 Martin Liska <mliska@suse.cz> PR tree-optimization/87954 diff --git a/gcc/config/msp430/msp430.md b/gcc/config/msp430/msp430.md index 344d21d..58c1f4e 100644 --- a/gcc/config/msp430/msp430.md +++ b/gcc/config/msp430/msp430.md @@ -756,8 +756,9 @@ (match_operand:HI 2 "general_operand")))] "" { - if (GET_CODE (operands[1]) == SUBREG - && REG_P (XEXP (operands[1], 0))) + if ((GET_CODE (operands[1]) == SUBREG + && REG_P (XEXP (operands[1], 0))) + || MEM_P (operands[1])) operands[1] = force_reg (HImode, operands[1]); if (msp430x && REG_P (operands[0]) @@ -828,8 +829,9 @@ (match_operand:HI 2 "general_operand")))] "" { - if (GET_CODE (operands[1]) == SUBREG - && REG_P (XEXP (operands[1], 0))) + if ((GET_CODE (operands[1]) == SUBREG + && REG_P (XEXP (operands[1], 0))) + || MEM_P (operands[1])) operands[1] = force_reg (HImode, operands[1]); if (msp430x && REG_P (operands[0]) @@ -916,8 +918,9 @@ (match_operand:HI 2 "general_operand")))] "" { - if (GET_CODE (operands[1]) == SUBREG - && REG_P (XEXP (operands[1], 0))) + if ((GET_CODE (operands[1]) == SUBREG + && REG_P (XEXP (operands[1], 0))) + || MEM_P (operands[1])) operands[1] = force_reg (HImode, operands[1]); if (msp430x && REG_P (operands[0]) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4bc2c29..c08d228 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-06-06 Jozef Lawrynowicz <jozef.l@mittosystems.com> + + * gcc.target/msp430/emulate-slli.c: New test. + * gcc.target/msp430/emulate-srai.c: New test. + * gcc.target/msp430/emulate-srli.c: New test. + 2019-06-06 Martin Liska <mliska@suse.cz> PR tree-optimization/87954 diff --git a/gcc/testsuite/gcc.target/msp430/emulate-slli.c b/gcc/testsuite/gcc.target/msp430/emulate-slli.c new file mode 100644 index 0000000..0ed09d5 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/emulate-slli.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ +/* { dg-final { scan-assembler-not "mspabi_slli" } } */ +/* { dg-final { scan-assembler "rlax" } } */ + +/* Ensure that HImode shifts with source operand in memory are emulated with a + rotate instructions. */ + +int a; + +void +foo (void) +{ + a = a << 4; +} diff --git a/gcc/testsuite/gcc.target/msp430/emulate-srai.c b/gcc/testsuite/gcc.target/msp430/emulate-srai.c new file mode 100644 index 0000000..6629171 --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/emulate-srai.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ +/* { dg-final { scan-assembler-not "mspabi_srai" } } */ +/* { dg-final { scan-assembler "rrax" } } */ + +/* Ensure that HImode shifts with source operand in memory are emulated with a + rotate instructions. */ + +int a; + +void +foo (void) +{ + a = a >> 4; +} diff --git a/gcc/testsuite/gcc.target/msp430/emulate-srli.c b/gcc/testsuite/gcc.target/msp430/emulate-srli.c new file mode 100644 index 0000000..c10f30b --- /dev/null +++ b/gcc/testsuite/gcc.target/msp430/emulate-srli.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ +/* { dg-final { scan-assembler-not "mspabi_srli" } } */ +/* { dg-final { scan-assembler "rrum" } } */ + +/* Ensure that HImode shifts with source operand in memory are emulated with a + rotate instructions. */ + +unsigned int a; + +void +foo (void) +{ + a = a >> 4; +} |