From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18294 invoked by alias); 10 Feb 2010 23:47:36 -0000 Received: (qmail 18242 invoked by uid 48); 10 Feb 2010 23:47:23 -0000 Date: Wed, 10 Feb 2010 23:47:00 -0000 Message-ID: <20100210234723.18241.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug rtl-optimization/39871] [4.3/4.4/4.5 regression] Code size increase on ARM due to poor register allocation In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "steven at gcc dot gnu dot org" 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 X-SW-Source: 2010-02/txt/msg01008.txt.bz2 ------- Comment #19 from steven at gcc dot gnu dot org 2010-02-10 23:47 ------- In r118474, cse.c:find_best_addr makes the replacement here: if ((addr_folded_cost < addr_cost || (addr_folded_cost == addr_cost /* ??? The rtx_cost comparison is left over from an older version of this code. It is probably no longer helpful.*/ && (rtx_cost (folded, MEM) > rtx_cost (addr, MEM) || approx_reg_cost (folded) < approx_reg_cost (addr)))) && validate_change (insn, loc, folded, 0)) addr = folded; All the costs are the same, except the approx_reg_cost tests: (gdb) p debug_rtx(addr) (plus:SI (reg/f:SI 102) (const_int 4 [0x4])) $35 = void (gdb) p debug_rtx(folded) (plus:SI (reg/f:SI 25 sfp) (const_int -8 [0xfffffffffffffff8])) $36 = void (gdb) p approx_reg_cost(addr) $37 = 1 (gdb) p approx_reg_cost(folded) $38 = 0 (gdb) The cost difference comes from approx_reg_cost_1, which uses CHEAP_REGNO for regs. CHEAP_REGNO prefers the frame pointer reg over normal pseudos: /* Compute cost of X, as stored in the `cost' field of a table_elt. Fixed hard registers and pointers into the frame are the cheapest with a cost of 0. Next come pseudos with a cost of one and other hard registers with a cost of 2. Aside from these special cases, call `rtx_cost'. */ #define CHEAP_REGNO(N) \ (REGNO_PTR_FRAME_P(N) \ || (HARD_REGISTER_NUM_P (N) \ && FIXED_REGNO_P (N) && REGNO_REG_CLASS (N) != NO_REGS)) This shouldn't be very difficult to teach fwprop about, too. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39871