Commit e445e4b4 by Jozef Lawrynowicz Committed by Jozef Lawrynowicz

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
parent d1b2f85f
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> 2019-06-06 Martin Liska <mliska@suse.cz>
PR tree-optimization/87954 PR tree-optimization/87954
......
...@@ -756,8 +756,9 @@ ...@@ -756,8 +756,9 @@
(match_operand:HI 2 "general_operand")))] (match_operand:HI 2 "general_operand")))]
"" ""
{ {
if (GET_CODE (operands[1]) == SUBREG if ((GET_CODE (operands[1]) == SUBREG
&& REG_P (XEXP (operands[1], 0))) && REG_P (XEXP (operands[1], 0)))
|| MEM_P (operands[1]))
operands[1] = force_reg (HImode, operands[1]); operands[1] = force_reg (HImode, operands[1]);
if (msp430x if (msp430x
&& REG_P (operands[0]) && REG_P (operands[0])
...@@ -828,8 +829,9 @@ ...@@ -828,8 +829,9 @@
(match_operand:HI 2 "general_operand")))] (match_operand:HI 2 "general_operand")))]
"" ""
{ {
if (GET_CODE (operands[1]) == SUBREG if ((GET_CODE (operands[1]) == SUBREG
&& REG_P (XEXP (operands[1], 0))) && REG_P (XEXP (operands[1], 0)))
|| MEM_P (operands[1]))
operands[1] = force_reg (HImode, operands[1]); operands[1] = force_reg (HImode, operands[1]);
if (msp430x if (msp430x
&& REG_P (operands[0]) && REG_P (operands[0])
...@@ -916,8 +918,9 @@ ...@@ -916,8 +918,9 @@
(match_operand:HI 2 "general_operand")))] (match_operand:HI 2 "general_operand")))]
"" ""
{ {
if (GET_CODE (operands[1]) == SUBREG if ((GET_CODE (operands[1]) == SUBREG
&& REG_P (XEXP (operands[1], 0))) && REG_P (XEXP (operands[1], 0)))
|| MEM_P (operands[1]))
operands[1] = force_reg (HImode, operands[1]); operands[1] = force_reg (HImode, operands[1]);
if (msp430x if (msp430x
&& REG_P (operands[0]) && REG_P (operands[0])
......
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> 2019-06-06 Martin Liska <mliska@suse.cz>
PR tree-optimization/87954 PR tree-optimization/87954
......
/* { 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;
}
/* { 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;
}
/* { 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment