[Bug target/86040] [avr]: RAMPZ is not always cleared after loading __flashN data

2019-10-18 Thread gjl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86040

Georg-Johann Lay  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #11 from Georg-Johann Lay  ---
Fixed in v7.5, v8.4 and v9.3+

[Bug target/86040] [avr]: RAMPZ is not always cleared after loading __flashN data

2019-10-18 Thread gjl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86040

--- Comment #10 from Georg-Johann Lay  ---
Author: gjl
Date: Fri Oct 18 09:16:16 2019
New Revision: 277149

URL: https://gcc.gnu.org/viewcvs?rev=277149=gcc=rev
Log:
Backport from 2019-10-18 trunk r277143.
PR target/86040
* config/avr/avr.c (avr_out_lpm): Do not shortcut-return.


Modified:
branches/gcc-7-branch/gcc/ChangeLog
branches/gcc-7-branch/gcc/config/avr/avr.c

[Bug target/86040] [avr]: RAMPZ is not always cleared after loading __flashN data

2019-10-18 Thread gjl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86040

--- Comment #9 from Georg-Johann Lay  ---
Author: gjl
Date: Fri Oct 18 09:12:34 2019
New Revision: 277148

URL: https://gcc.gnu.org/viewcvs?rev=277148=gcc=rev
Log:
Backport from 2019-10-18 trunk r277143.
PR target/86040
* config/avr/avr.c (avr_out_lpm): Do not shortcut-return.


Modified:
branches/gcc-8-branch/gcc/ChangeLog
branches/gcc-8-branch/gcc/config/avr/avr.c

[Bug target/86040] [avr]: RAMPZ is not always cleared after loading __flashN data

2019-10-18 Thread gjl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86040

--- Comment #8 from Georg-Johann Lay  ---
Author: gjl
Date: Fri Oct 18 09:10:20 2019
New Revision: 277147

URL: https://gcc.gnu.org/viewcvs?rev=277147=gcc=rev
Log:
Backport from 2019-10-18 trunk r277143.
PR target/86040
* config/avr/avr.c (avr_out_lpm): Do not shortcut-return.


Modified:
branches/gcc-9-branch/gcc/ChangeLog
branches/gcc-9-branch/gcc/config/avr/avr.c

[Bug target/86040] [avr]: RAMPZ is not always cleared after loading __flashN data

2019-10-18 Thread gjl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86040

--- Comment #7 from Georg-Johann Lay  ---
Author: gjl
Date: Fri Oct 18 06:53:34 2019
New Revision: 277143

URL: https://gcc.gnu.org/viewcvs?rev=277143=gcc=rev
Log:
PR target/86040
* config/avr/avr.c (avr_out_lpm): Do not shortcut-return.


Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/avr/avr.c

[Bug target/86040] [avr]: RAMPZ is not always cleared after loading __flashN data

2019-10-09 Thread gjl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86040

--- Comment #6 from Georg-Johann Lay  ---
Created attachment 47009
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47009=edit
proposed patch

[Bug target/86040] [avr]: RAMPZ is not always cleared after loading __flashN data

2018-07-22 Thread gjl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86040

--- Comment #5 from Georg-Johann Lay  ---
Created attachment 44416
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44416=edit
C test case for movmem

The movmem from ASes __flash1 ... __flash5 is also affected.  As the place to
fix I'd propose the output function avr.c::avr_out_movmem().

[Bug target/86040] [avr]: RAMPZ is not always cleared after loading __flashN data

2018-07-19 Thread gjl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86040

--- Comment #4 from Georg-Johann Lay  ---
Created attachment 44412
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44412=edit
C test case.

[Bug target/86040] [avr]: RAMPZ is not always cleared after loading __flashN data

2018-07-19 Thread gjl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86040

--- Comment #3 from Georg-Johann Lay  ---
...and here is code that triggers the wrong path of the 2-byte case:

typedef struct S
{
const __flash2 struct S *p;
struct S *q;
} S;

const __flash2 S* func2 (const S *s)
{
return s->p->q->p;
}

$ avr-gcc -std=gnu99 -mmcu=atxmega128a1 -S foo.c -Os -dp

func2:
movw r26,r24 ;  20  [c=4 l=1]  *movhi/0
ld r30,X+;  6   [c=8 l=2]  *movhi/2
ld r31,X
adiw r30,2   ;  8   [c=4 l=1]  addhi3_clobber/0
ldi r18,2;  9   [c=8 l=5]  *movhi/2
out __RAMPZ__,r18
elpm r0,Z+
elpm r31,Z
mov r30,r0
ld r24,Z ;  15  [c=8 l=2]  *movhi/2
ldd r25,Z+1
/* epilogue start */
ret  ;  23  [c=0 l=1]  return

Insn 9 is missing the reset of RAMPZ so that insn 15 loads with a high-byte of
2.

[Bug target/86040] [avr]: RAMPZ is not always cleared after loading __flashN data

2018-07-16 Thread gjl at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86040

Georg-Johann Lay  changed:

   What|Removed |Added

   Keywords||wrong-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2018-07-16
 Ever confirmed|0   |1

--- Comment #2 from Georg-Johann Lay  ---
IMO the problem are the early returns in avr.c::avr_out_lpm() that bypass the
reset to 0 of RAMPZ at the end of that function if RAMPD is present:

http://gcc.gnu.org/viewcvs/gcc/trunk/gcc/config/avr/avr.c?view=markup=257301#l3703

Affected is code for the devices in -mmcu=avrxmega5 and avrxmega7. A test case
for 1-byte reads is

char func1 (const __flash2 char *p)
{
return *p;
}

func1:
movw r30,r24 ;  16  [c=4 l=1]  *movhi/0
ldi r18,2;  11  [c=4 l=3]  movqi_insn/3
out __RAMPZ__,r18
elpm r24,Z
/* epilogue start */
ret  ;  19  [c=0 l=1]  return

I found no code to cover the wrong parts of the 2-byte and 4-byte reads.

[Bug target/86040] [avr]: RAMPZ is not always cleared after loading __flashN data

2018-06-04 Thread lmorrison at nautel dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86040

--- Comment #1 from Luke Morrison  ---
Created attachment 44231
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44231=edit
Compiled output from avr-gcc 8.1.0 of the test case.