public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/64331] New: regcprop propagates registers noted as REG_DEAD
@ 2014-12-16 13:07 senthil_kumar.selvaraj at atmel dot com
  2014-12-16 13:08 ` [Bug rtl-optimization/64331] " senthil_kumar.selvaraj at atmel dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: senthil_kumar.selvaraj at atmel dot com @ 2014-12-16 13:07 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64331
           Summary: regcprop propagates registers noted as REG_DEAD
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: senthil_kumar.selvaraj at atmel dot com

Created attachment 34290
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34290&action=edit
Source file

For the AVR target, compiling the attached source file with -O1 results in code
like this

<snip>
        or r20,r21
        or r20,r22
        or r20,r23
        breq .L1
        ldd r24,Z+4
        ldd r25,Z+5
        ldd r26,Z+6
        ldd r27,Z+7
        cp r20,r24
        cpc r21,r25
        cpc r22,r26
        cpc r23,r27
</snip>

Register R20 was clobbered first up, but is used to compare against R24.

fdump-rtl-all-raw showed that cprop_hardreg is the culprit. In pass *.ce3

<snip>
(insn 7 4 8 2 (set (reg:SI 16 r16 [orig:43 D.1617 ] [43]) 
        (reg/v:SI 20 r20 [orig:46 x ] [46])) reduced.c:12 94 {*movsi}
     (nil))
...
(insn 13 12 14 3 (parallel [
            (set (cc0)
                (compare (reg/v:SI 20 r20 [orig:46 x ] [46])
                    (const_int 0 [0])))
            (clobber (scratch:QI))
        ]) reduced.c:17 413 {*cmpsi}
     (expr_list:REG_DEAD (reg/v:SI 20 r20 [orig:46 x ] [46])
        (nil)))
...
(insn 17 16 18 4 (parallel [
            (set (cc0)
                (compare (reg:SI 16 r16 [orig:43 D.1617 ] [43])
                    (reg:SI 24 r24 [orig:48 t_3(D)->b ] [48])))
            (clobber (scratch:QI))
        ]) reduced.c:20 413 {*cmpsi}
     (expr_list:REG_DEAD (reg:SI 24 r24 [orig:48 t_3(D)->b ] [48])
        (expr_list:REG_DEAD (reg:SI 16 r16 [orig:43 D.1617 ] [43])
            (nil))))
</snip>

into

<snip>
;; Function foo (foo, funcdef_no=0, decl_uid=1599, cgraph_uid=0,
symbol_order=0)

insn 17: replaced reg 16 with 20
rescanning insn with uid = 17.
..
(insn 17 16 18 4 (parallel [
            (set (cc0)
                (compare (reg:SI 20 r20 [orig:43 D.1617 ] [43])
                    (reg:SI 24 r24 [orig:48 t_3(D)->b ] [48])))
            (clobber (scratch:QI))
        ]) reduced.c:20 413 {*cmpsi}
     (expr_list:REG_DEAD (reg:SI 24 r24 [orig:48 t_3(D)->b ] [48])
        (expr_list:REG_DEAD (reg:SI 16 r16 [orig:43 D.1617 ] [43])
            (nil))))
</snip>

The AVR backend, on seeing that reg:SI r20 is dead in insn 13, emits code that
clobbers r20, and this breaks the read in insn 17.


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-05-28 17:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-16 13:07 [Bug rtl-optimization/64331] New: regcprop propagates registers noted as REG_DEAD senthil_kumar.selvaraj at atmel dot com
2014-12-16 13:08 ` [Bug rtl-optimization/64331] " senthil_kumar.selvaraj at atmel dot com
2014-12-16 14:31 ` [Bug target/64331] " rguenth at gcc dot gnu.org
2014-12-16 16:24 ` ebotcazou at gcc dot gnu.org
2014-12-17  2:34 ` senthil_kumar.selvaraj at atmel dot com
2014-12-17 15:12 ` ebotcazou at gcc dot gnu.org
2015-02-20 17:11 ` gjl at gcc dot gnu.org
2015-03-03 11:10 ` gjl at gcc dot gnu.org
2015-03-03 11:25 ` gjl at gcc dot gnu.org
2015-03-03 11:36 ` gjl at gcc dot gnu.org
2015-04-22 12:01 ` jakub at gcc dot gnu.org
2015-07-16  9:18 ` rguenth at gcc dot gnu.org
2015-09-28 16:27 ` olegendo at gcc dot gnu.org
2022-01-09  0:43 ` pinskia at gcc dot gnu.org
2023-05-28 17:02 ` gjl at gcc dot gnu.org
2023-05-28 17:02 ` gjl at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).