This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc4.6.0:combining operate+test
- From: cirrus75 <cirrus75 at uol dot com dot br>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 12 Apr 2011 17:16:11 -0300
- Subject: gcc4.6.0:combining operate+test
Hi All,
I have been looking at a case in x86 architecture where gcc could generate better code for:
if(a+=25)
d=c;
Insns for operation and test are:
(insn 5 2 6 2 (set (reg:SI 62 [ a ])
(mem/c/i:SI (symbol_ref:DI ("a") <var_decl 0x2aaaae259500 a>) [2 a+0 S4 A32])) test_and.c:9 64 {*movsi_internal}
(nil))
(insn 6 5 7 2 (parallel [
(set (reg:SI 60 [ a.1 ])
(plus:SI (reg:SI 62 [ a ])
(const_int 25 [0x19])))
(clobber (reg:CC 17 flags))
]) test_and.c:9 252 {*addsi_1}
(expr_list:REG_DEAD (reg:SI 62 [ a ])
(expr_list:REG_UNUSED (reg:CC 17 flags)
(expr_list:REG_EQUAL (plus:SI (mem/c/i:SI (symbol_ref:DI ("a") <var_decl 0x2aaaae259500 a>) [2 a+0 S4 A32])
(const_int 25 [0x19]))
(nil)))))
(insn 7 6 8 2 (set (mem/c/i:SI (symbol_ref:DI ("a") <var_decl 0x2aaaae259500 a>) [2 a+0 S4 A32])
(reg:SI 60 [ a.1 ])) test_and.c:9 64 {*movsi_internal}
(nil))
(insn 8 7 9 2 (set (reg:CCZ 17 flags)
(compare:CCZ (reg:SI 60 [ a.1 ])
(const_int 0 [0]))) test_and.c:9 2 {*cmpsi_ccno_1}
(nil))
I noticed combine.c is not able to combine insns 6 and 8. This is because create_log_links function only creates (as far as I could understand) links between the reg setter and the first reg user, but not the other reg users. Thus, combine.c do try to combine 6 and 7, but without success.
Why does not create_log_links create links between the reg setter and all the reg users ?
I compiled it on powerpc and got the same results (3 instructions: operate, store, test), so this behavior affects not only x86 architectures. It seems something good to optimize.
best regards,
Alex Rocha Prado