From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19532 invoked by alias); 16 Dec 2014 13:07:38 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 19509 invoked by uid 48); 16 Dec 2014 13:07:34 -0000 From: "senthil_kumar.selvaraj at atmel dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/64331] New: regcprop propagates registers noted as REG_DEAD Date: Tue, 16 Dec 2014 13:07:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: senthil_kumar.selvaraj at atmel dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-12/txt/msg01871.txt.bz2 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 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 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 (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)))) into ;; 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)))) 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.