Commit d8e4dc54 by Jozef Lawrynowicz Committed by Jozef Lawrynowicz

MSP430: Tweaks to generation of 430X instructions

gcc/ChangeLog:

2019-10-24  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	* config/msp430/constraints.md: Allow post_inc for "Ya" constraint.
	* config/msp430/msp430.md (430x_shift_left): Use RLAM when the constant
	shift amount is between 1 and 4.
	(430x_arithmetic_shift_right): Use RRAM when the constant shift amount
	is between 1 and 4.

gcc/testsuite/ChangeLog:

2019-10-24  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	* gcc.target/msp430/emulate-slli.c: Skip for -mcpu=msp430.
	Add shift by a constant 5 bits.
	Update scan-assembler directives.
	* gcc.target/msp430/emulate-srai.c: Likewise.
	* gcc.target/msp430/emulate-srli.c: Skip for -mcpu=msp430.

From-SVN: r277394
parent e2275947
2019-10-24 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* config/msp430/constraints.md: Allow post_inc for "Ya" constraint.
* config/msp430/msp430.md (430x_shift_left): Use RLAM when the constant
shift amount is between 1 and 4.
(430x_arithmetic_shift_right): Use RRAM when the constant shift amount
is between 1 and 4.
2019-10-24 Richard Biener <rguenther@suse.de> 2019-10-24 Richard Biener <rguenther@suse.de>
PR tree-optimization/92205 PR tree-optimization/92205
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
(match_test ("CONST_INT_P (XEXP (XEXP (op, 0), 1))")) (match_test ("CONST_INT_P (XEXP (XEXP (op, 0), 1))"))
(match_test ("IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), HOST_WIDE_INT_M1U << 15, (1 << 15)-1)")))) (match_test ("IN_RANGE (INTVAL (XEXP (XEXP (op, 0), 1)), HOST_WIDE_INT_M1U << 15, (1 << 15)-1)"))))
(match_code "reg" "0") (match_code "reg" "0")
(match_code "post_inc" "0")
))) )))
(define_constraint "Yc" (define_constraint "Yc"
......
...@@ -875,8 +875,10 @@ ...@@ -875,8 +875,10 @@
(match_operand 2 "immediate_operand" "n")))] (match_operand 2 "immediate_operand" "n")))]
"msp430x" "msp430x"
"* "*
if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 16) if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 5)
return \"rpt\t%2 { rlax.w\t%0\"; return \"RLAM.W\t%2, %0\";
else if (INTVAL (operands[2]) >= 5 && INTVAL (operands[2]) < 16)
return \"RPT\t%2 { RLAX.W\t%0\";
return \"# nop left shift\"; return \"# nop left shift\";
" "
) )
...@@ -960,8 +962,10 @@ ...@@ -960,8 +962,10 @@
(match_operand 2 "immediate_operand" "n")))] (match_operand 2 "immediate_operand" "n")))]
"msp430x" "msp430x"
"* "*
if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 16) if (INTVAL (operands[2]) > 0 && INTVAL (operands[2]) < 5)
return \"rpt\t%2 { rrax.w\t%0\"; return \"RRAM.W\t%2, %0\";
else if (INTVAL (operands[2]) >= 5 && INTVAL (operands[2]) < 16)
return \"RPT\t%2 { RRAX.W\t%0\";
return \"# nop arith right shift\"; return \"# nop arith right shift\";
" "
) )
......
2019-10-24 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* gcc.target/msp430/emulate-slli.c: Skip for -mcpu=msp430.
Add shift by a constant 5 bits.
Update scan-assembler directives.
* gcc.target/msp430/emulate-srai.c: Likewise.
* gcc.target/msp430/emulate-srli.c: Skip for -mcpu=msp430.
2019-10-24 Richard Biener <rguenther@suse.de> 2019-10-24 Richard Biener <rguenther@suse.de>
PR tree-optimization/92205 PR tree-optimization/92205
......
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-mcpu=msp430" } { "" } } */
/* { dg-options "-Os" } */ /* { dg-options "-Os" } */
/* { dg-final { scan-assembler-not "mspabi_slli" } } */ /* { dg-final { scan-assembler-not "mspabi_slli" } } */
/* { dg-final { scan-assembler "rlax" } } */ /* { dg-final { scan-assembler "RLAM.W\t#4" } } */
/* { dg-final { scan-assembler "RPT\t#5 \{ RLAX.W" } } */
/* Ensure that HImode shifts with source operand in memory are emulated with a /* Ensure that HImode shifts with source operand in memory are emulated with a
rotate instructions. */ rotate instructions. */
int a; int a;
int b;
void void
foo (void) foo (void)
{ {
a = a << 4; a = a << 4;
b = b << 5;
} }
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-mcpu=msp430" } { "" } } */
/* { dg-options "-Os" } */ /* { dg-options "-Os" } */
/* { dg-final { scan-assembler-not "mspabi_srai" } } */ /* { dg-final { scan-assembler-not "mspabi_srai" } } */
/* { dg-final { scan-assembler "rrax" } } */ /* { dg-final { scan-assembler "RRAM.W\t#4" } } */
/* { dg-final { scan-assembler "RPT\t#5 \{ RRAX.W" } } */
/* Ensure that HImode shifts with source operand in memory are emulated with a /* Ensure that HImode shifts with source operand in memory are emulated with a
rotate instructions. */ rotate instructions. */
int a; int a;
int b;
void void
foo (void) foo (void)
{ {
a = a >> 4; a = a >> 4;
b = b >> 5;
} }
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-skip-if "" { *-*-* } { "-mcpu=msp430" } { "" } } */
/* { dg-options "-Os" } */ /* { dg-options "-Os" } */
/* { dg-final { scan-assembler-not "mspabi_srli" } } */ /* { dg-final { scan-assembler-not "mspabi_srli" } } */
/* { dg-final { scan-assembler "rrum" } } */ /* { dg-final { scan-assembler "rrum" } } */
......
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