https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117191

            Bug ID: 117191
           Summary: [avr][dse2][lra] wrong dead store elimination
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: testsuite-fail, wrong-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: denisc at gcc dot gnu.org
  Target Milestone: ---
            Target: avr

Created attachment 59370
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59370&action=edit
dse2 pass dump file

Failed testcase:
$ make -k check-gcc RUNTESTFLAGS="--target_board=atmega128-sim
--tool_opts='-mlra' avr-torture.exp=lra-pr116550-2.c"
[...]
Running /mnt/d/gcc-avr-lra/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp
...
FAIL: gcc.target/avr/torture/lra-pr116550-2.c   -O1  execution test

                === gcc Summary ===

# of expected passes            21
# of unexpected failures        1
/mnt/d/mk-avr-lra/gcc/xgcc  version 15.0.0 20241016 (experimental) (GCC) 
[...]


This test successfully passed without -mlra option, may be lra related:
$ make -k check-gcc RUNTESTFLAGS="--target_board=atmega128-sim
--tool_opts='-mno-lra' avr-torture.exp=lra-pr116550-2.c"
[...]
Running /mnt/d/gcc-avr-lra/gcc/testsuite/gcc.target/avr/torture/avr-torture.exp
...

                === gcc Summary ===

# of expected passes            22
/mnt/d/mk-avr-lra/gcc/xgcc  version 15.0.0 20241016 (experimental) (GCC) 
[...]

Testcase 

$ avr-gcc -da -O1 -S -dp -fverbose-asm -mmcu=atmega128 lra-pr116550-2.c


dse2 pass made a wrong elimination of insn 554 (%sfp+13)
insn 456 have a use of *(%sfp+13):QI
probably scanning of it have to be like:
**scanning insn=505
  mem: (plus:HI (reg/f:HI 28 r28)
    (const_int 5 [0x5]))

   after canon_rtx address: (plus:HI (reg/f:HI 28 r28)
    (const_int 5 [0x5]))
  gid=1 offset=5
 processing const load gid=1[5..6)
removing from active insn=459 has store
mems_found = 0, cannot_delete = true

but it's
**scanning insn=456
  mem: (plus:HI (reg/f:HI 28 r28)
    (const_int 13 [0xd]))

   after canon_rtx address: (plus:HI (reg/f:HI 28 r28)
    (const_int 13 [0xd]))
  gid=1 offset=13
 processing const load gid=1[13..14)
mems_found = 0, cannot_delete = true

Scanning of insn 456 doesn't have 'removing from active insn=554 has store'
because of that insn 554 was removed but it have a store to *(%sfp+13)
It's wrong because insn 456 have a use of *(%sfp+13)

Reply via email to