This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/25381] New: local alloc is not really that good
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Dec 2005 05:07:59 -0000
- Subject: [Bug rtl-optimization/25381] New: local alloc is not really that good
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Take this little (stupid) C example:
int f1(int a)
{
int b = a*2;
return b+a;
}
---
Currently we produce:
_f1:
mr r0,r3
slwi r3,r3,1
add r3,r3,r0
blr
-----
We should be able to produce:
_f1:
slwi r0,r3,1
add r3,r3,r0
blr
-------
If we look at the RTL which used:
(insn:HI 6 17 12 0 (set (reg/v:SI 121 [ a ])
(reg:SI 3 r3 [ a ])) 326 {*movsi_internal1} (nil)
(expr_list:REG_DEAD (reg:SI 3 r3 [ a ])
(expr_list:REG_EQUIV (mem/c/i:SI (plus:SI (reg/f:SI 67 ap)
(const_int 24 [0x18])) [2 a+0 S4 A32])
(nil))))
(insn:HI 12 6 20 0 (set (reg/v:SI 119 [ b ])
(ashift:SI (reg/v:SI 121 [ a ])
(const_int 1 [0x1]))) 188 {ashlsi3_no_power}
(insn_list:REG_DEP_TRUE 6 (nil))
(nil))
(insn:HI 20 12 26 0 (set (reg/i:SI 3 r3 [ <result> ])
(plus:SI (reg/v:SI 119 [ b ])
(reg/v:SI 121 [ a ]))) 94 {*addsi3_internal1}
(insn_list:REG_DEP_TRUE 6 (insn_list:REG_DEP_TRUE 12 (nil)))
(expr_list:REG_DEAD (reg/v:SI 119 [ b ])
(expr_list:REG_DEAD (reg/v:SI 121 [ a ])
(nil))))
------
And then look at what local alloc does:
Pass 0
Register 119 costs: BASE_REGS:0 GENERAL_REGS:0 NON_SPECIAL_REGS:4000
LINK_REGS:4000 CTR_REGS:4000 LINK_OR_CTR_REGS:4000 SPECIAL_REGS:4000
SPEC_OR_GEN_REGS:4000 NON_FLOAT_REGS:4000 ALL_REGS:4000 MEM:8000
Register 121 costs: BASE_REGS:0 GENERAL_REGS:0 NON_SPECIAL_REGS:6000
LINK_REGS:6000 CTR_REGS:6000 LINK_OR_CTR_REGS:6000 SPECIAL_REGS:6000
SPEC_OR_GEN_REGS:6000 NON_FLOAT_REGS:6000 ALL_REGS:6000 MEM:12000
Register 119 pref GENERAL_REGS
Register 121 pref GENERAL_REGS
Pass 1
Register 119 costs: BASE_REGS:0 GENERAL_REGS:0 NON_SPECIAL_REGS:4000
LINK_REGS:4000 CTR_REGS:4000 LINK_OR_CTR_REGS:4000 SPECIAL_REGS:4000
SPEC_OR_GEN_REGS:4000 NON_FLOAT_REGS:4000 ALL_REGS:4000 MEM:8000
Register 121 costs: BASE_REGS:0 GENERAL_REGS:0 NON_SPECIAL_REGS:6000
LINK_REGS:6000 CTR_REGS:6000 LINK_OR_CTR_REGS:6000 SPECIAL_REGS:6000
SPEC_OR_GEN_REGS:6000 NON_FLOAT_REGS:6000 ALL_REGS:6000 MEM:12000
123 registers.
Register 119 used 2 times across 2 insns in block 0; set 1 time; user var.
Register 121 used 3 times across 6 insns in block 0; set 1 time; user var.
1 basic blocks, 2 edges.
Basic block 0 prev -1, next -2, loop_depth 0, count 0, freq 10000, maybe hot.
Predecessors: ENTRY [100.0%] (fallthru)
Successors: EXIT [100.0%] (fallthru)
Registers live at start: 1 [r1] 3 [r3] 30 [r30] 67 [ap] 113 [sfp]
Registers live at end: 1 [r1] 3 [r3] 30 [r30] 67 [ap] 113 [sfp]
;; Register 119 in 3.
;; Register 121 in 0.
------
it puts 119 in r3 and 121 in r0, when the opposite is better.
--
Summary: local alloc is not really that good
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: missed-optimization, ra
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: pinskia at gcc dot gnu dot org
GCC build triplet: powerpc-darwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25381