Bug 56833 - [4.9 Regression] Valid register is over written by postreload pass
Summary: [4.9 Regression] Valid register is over written by postreload pass
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: 4.9.0
Assignee: Not yet assigned to anyone
Keywords: patch, wrong-code
: 50891 (view as bug list)
Depends on: 57439
Blocks: 56183
  Show dependency treegraph
Reported: 2013-04-03 12:40 UTC by vishnu ks
Modified: 2021-09-13 11:40 UTC (History)
5 users (show)

See Also:
Target: avr
Known to work:
Known to fail:
Last reconfirmed: 2013-05-15 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description vishnu ks 2013-04-03 12:40:52 UTC
AVR target built with specs:

Using built-in specs.
Target: avr
Configured with: ../gcc-trunk/configure --prefix=/home/vishnu.k_s/build-linux_x86_64//install --target=avr --enable-languages=c,c++ --disable-nls --with-gmp=/proj/install/gmp-4.3.2/ --with-mpfr=/proj/install/mpfr-2.4.2/ --with-mpc=/proj/install/mpc-0.8.2/
Thread model: single
gcc version 4.9.0 20130326 (experimental) (GCC)

Above compiler generate wrong code for testcase present in gcc.c-torture/execute/simd-1.c.
gcc options : -O1 -mmcu=atmega1280

(snip of assembly)

ldi r30,lo8(res)    ; r30/r31 is loaded with address of res
ldi r31,hi8(res)    ;
st Z,r24   

ldd r31,Y+1         ;    Modifying r31 register

sts res+1,r31
sts res+2,r27
sts res+3,r26
sts res+4,r23
lds r22,res+4+2
lds r23,res+4+3

ld r24,Z             ; regsiter pair r30/r31 is used to load from res
ldd r25,Z+1
ldd r26,Z+2
ldd r27,Z+3

(snip of assembly)

It looks like r31 is corrupted after reload pass.
Comment 1 vishnu ks 2013-04-03 12:50:55 UTC
This bug might be similar to PR56442, which is not reproducible in 4.9.
conversation in mailing list : http://gcc.gnu.org/ml/gcc/2013-03/msg00121.html
Comment 2 Jorn Wolfgang Rennecke 2013-05-14 15:43:35 UTC
It's a postreload bug.
Comment 3 Jorn Wolfgang Rennecke 2013-05-15 15:02:27 UTC
The patch has been posted:
Comment 4 Jorn Wolfgang Rennecke 2013-05-27 14:10:26 UTC
        PR rtl-optimization/56833
        * postreload.c (move2add_record_mode): New function.
        (move2add_record_sym_value, move2add_valid_value_p): Likewise.
        (move2add_use_add2_insn): Use move2add_record_sym_value.
        (move2add_use_add3_insn): Likewise.
        (reload_cse_move2add): Use move2add_valid_value_p and
        move2add_record_mode.  Invalidate call-clobbered and REG_INC
        affected regs by setting reg_mode to VOIDmode.
        (move2add_note_store): Don't pretend the inside of a SUBREG is
        the actual destination.  Invalidate single/leading registers by
        setting reg_mode to VOIDmode.
        Use move2add_record_sym_value, move2add_valid_value_p and
Comment 5 Georg-Johann Lay 2013-05-28 17:30:05 UTC
This PR looks similar to PR56442 for the 4.8 branch.  Does your patch fix that problem, too?
Comment 6 H.J. Lu 2021-09-13 11:40:52 UTC
*** Bug 50891 has been marked as a duplicate of this bug. ***