This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/65379] New: ifcvt does not clean up dead instructions
- From: "krebbel at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 10 Mar 2015 16:40:09 +0000
- Subject: [Bug rtl-optimization/65379] New: ifcvt does not clean up dead instructions
- Auto-submitted: auto-generated
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 ])))
])