From 8e916b1650bfb449cf121b432d7f08e210f1782f Mon Sep 17 00:00:00 2001 From: Pitchumani Sivanupandi Date: Sat, 21 May 2016 10:47:27 +0000 Subject: [PATCH] re PR target/71103 (avr-gcc crashes with unrecognizable insn error) PR target/71103 * config/avr/avr.md (define_expand "mov"): If the source operand is subreg (symbol_ref) then move the symbol ref to register. PR target/71103 * gcc.target/avr/pr71103.c: New test. From-SVN: r236558 --- gcc/ChangeLog | 6 ++++++ gcc/config/avr/avr.md | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/avr/pr71103.c | 16 ++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 gcc/testsuite/gcc.target/avr/pr71103.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a4cdb4e1052..8652f5c2911 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-05-21 Pitchumani Sivanupandi + + PR target/71103 + * config/avr/avr.md (define_expand "mov"): If the source + operand is subreg (symbol_ref) then move the symbol ref to register. + 2016-05-21 Jan Hubicka * tree.c (array_at_struct_end_p): Look through MEM_REF. diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md index c9884461841..927bc6967a1 100644 --- a/gcc/config/avr/avr.md +++ b/gcc/config/avr/avr.md @@ -638,6 +638,13 @@ rtx dest = operands[0]; rtx src = avr_eval_addr_attrib (operands[1]); + if (SUBREG_P(src) && (GET_CODE(XEXP(src,0)) == SYMBOL_REF) && + can_create_pseudo_p()) + { + rtx symbol_ref = XEXP(src, 0); + XEXP (src, 0) = copy_to_mode_reg (GET_MODE(symbol_ref), symbol_ref); + } + if (avr_mem_flash_p (dest)) DONE; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3fc92f10d66..a409b88e954 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-05-20 Pitchumani Sivanupandi + + PR target/71103 + * gcc.target/avr/pr71103.c: New test. + 2016-05-21 Kugan Vivekanandarajah PR middle-end/71179 diff --git a/gcc/testsuite/gcc.target/avr/pr71103.c b/gcc/testsuite/gcc.target/avr/pr71103.c new file mode 100644 index 00000000000..43244d15e97 --- /dev/null +++ b/gcc/testsuite/gcc.target/avr/pr71103.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +struct ResponseStruct{ + unsigned char responseLength; + char *response; +}; + +static char response[5]; +struct ResponseStruct something(){ + struct ResponseStruct returnValue; + returnValue.responseLength = 5; + returnValue.response = response; + return returnValue; +} + -- 2.30.2