Bug 117910 - [avr][lra] Wrong code with -mlra in cmpdi-1.c
Summary: [avr][lra] Wrong code with -mlra in cmpdi-1.c
Status: RESOLVED DUPLICATE of bug 117868
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 15.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ra, wrong-code
Depends on:
Blocks: avr+ra 113934
  Show dependency treegraph
 
Reported: 2024-12-04 11:37 UTC by Georg-Johann Lay
Modified: 2025-01-12 13:27 UTC (History)
1 user (show)

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Reduced C test case from cmpdi-1.c (706 bytes, text/x-csrc)
2024-12-04 11:37 UTC, Georg-Johann Lay
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Georg-Johann Lay 2024-12-04 11:37:35 UTC
Created attachment 59782 [details]
Reduced C test case from cmpdi-1.c

There is yet another fail with -mlra with the attached cmpdi-1.c that produces wrong code.

$avr-gcc -mmcu=atmega128 -dumpbase "" -save-temps -dp -Os -o cmpdi-1.elf -mlra -fverbose-asm cmpdi-1.c

Notice the following load / stores involving Y+12 and X+12 in cmpdi-1.s:

   std Y+13,r25	 ;  %sfp, _51	 ;  685	[c=4 l=2]  *movhi/3
   std Y+12,r24	 ;  %sfp, _51
...
   std Y+12,r25	 ;  %sfp, tmp162 ;  588	[c=4 l=2]  *movhi/3
   std Y+11,r24	 ;  %sfp, tmp162
...
   std Y+11,r24	 ;  %sfp, arg1	 ;  615	[c=4 l=1]  movqi_insn/2
...
   ldd r16,Y+11	 ; , %sfp	 ;  640	[c=4 l=1]  movqi_insn/3
...
   std Y+12,r9	 ;  %sfp, res	 ;  439	[c=4 l=2]  *movhi/3
   std Y+11,r8	 ;  %sfp, res
...
   ldd r24,Y+12	 ;  _51, %sfp	 ;  435	[c=8 l=2]  *movhi/2
   ldd r25,Y+13	 ;  _51, %sfp

So it seems LRA is trampling some values / is using wrong offsets.

Target: avr
Configured with: ../../source/gcc-master/configure --target=avr --disable-nls --with-dwarf2 --with-gnu-as --with-gnu-ld --with-long-double=64 --enable-languages=c,c++
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 15.0.0 20241203 (experimental) (GCC)
Comment 1 Georg-Johann Lay 2024-12-04 12:24:46 UTC
(In reply to Georg-Johann Lay from comment #0)
> ...involving Y+12 and X+12 in cmpdi-1.s
Meant "Y+12 and Y+11".
Comment 2 Georg-Johann Lay 2025-01-12 13:27:54 UTC
Dup

*** This bug has been marked as a duplicate of bug 117868 ***