From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 90183 invoked by alias); 10 Mar 2015 16:40:14 -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 90032 invoked by uid 48); 10 Mar 2015 16:40:11 -0000 From: "krebbel at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/65379] New: ifcvt does not clean up dead instructions Date: Tue, 10 Mar 2015 16:40: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: krebbel at gcc dot gnu.org 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: 2015-03/txt/msg01140.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65379 Bug ID: 65379 Summary: ifcvt does not clean up dead instructions Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: krebbel at gcc dot gnu.org Created attachment 35002 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35002&action=edit Experimental and way too expensive fix the combine pass sometimes gets confused by already dead compares which are remains of the if conversion pass. This e.g. happens in gcc.dg/builtin-bswap-7.c. Compiling with -march=z196 the if blocks are modified to make use of load on condition. This duplicates the compare insn but unfortunately ifcvt fails to clean it up and the additional compare survives until the second ifcvt pass. Combine fails to do the simplification of the bswap since the bswapped value appears to be used in the second compare as well. ifcvt runs df_analyze in a loop until nothing changes anymore. So this loop is always left with all df solutions being clean. However, dce is only run once, before the first iteration. ce1: (insn 2 4 3 2 (set (reg/v:DI 64 [ a ]) (reg:DI 2 %r2 [ a ])) /home3/andreas/gcc/gcc/testsuite/gcc.dg/builtin-bswap-7.c:15 863 {*movdi_64} (expr_list:REG_DEAD (reg:DI 2 %r2 [ a ]) (nil))) (note 3 2 6 2 NOTE_INSN_FUNCTION_BEG) (insn 6 3 7 2 (set (reg:DI 60 [ D.2056 ]) (bswap:DI (reg/v:DI 64 [ a ]))) /home3/andreas/gcc/gcc/testsuite/gcc.dg/builtin-bswap-7.c:16 1501 {bswapdi2} (expr_list:REG_DEAD (reg/v:DI 64 [ a ]) (nil))) (insn 7 6 8 2 (set (reg:SI 66 [ D.2057+-3 ]) (const_int 1 [0x1])) 867 {*movsi_zarch} (nil)) (insn 8 7 22 2 (set (reg:CCZ 33 %cc) (compare:CCZ (reg:DI 60 [ D.2056 ]) (const_int 42949672960 [0xa00000000]))) 822 {*cmpdi_cct} (expr_list:REG_DEAD (reg:DI 60 [ D.2056 ]) (nil))) (insn 22 8 23 2 (set (reg:SI 70) (const_int 1 [0x1])) 867 {*movsi_zarch} (nil)) (insn 23 22 24 2 (set (reg:SI 71) (const_int 0 [0])) 867 {*movsi_zarch} (nil)) (insn 24 23 25 2 (set (reg:CCZ 33 %cc) (compare:CCZ (reg:DI 60 [ D.2056 ]) (const_int 42949672960 [0xa00000000]))) 822 {*cmpdi_cct} (nil)) (insn 25 24 12 2 (set (reg:SI 66 [ D.2057+-3 ]) (if_then_else:SI (eq (reg:CCZ 33 %cc) (const_int 0 [0])) (reg:SI 70) (reg:SI 71))) 1234 {*movsicc} Hence combine must assume that r60 is still needed for insn 24 although this insn should have been removed already. Combine tries to match the following insn what fails: (parallel [ (set (reg:CCZ 33 %cc) (compare:CCZ (bswap:DI (reg:DI 2 %r2 [ a ])) (const_int 42949672960 [0xa00000000]))) (set (reg:DI 60 [ D.2056 ]) (bswap:DI (reg:DI 2 %r2 [ a ]))) ])