From: wilco Date: Thu, 28 Jul 2016 14:29:28 +0000 (+0000) Subject: This patchset improves zero extend costs and code generation. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9b820efefdd7b3ed5ec5cc54cd93abbf7a3c53a9;p=thirdparty%2Fgcc.git This patchset improves zero extend costs and code generation. When zero extending a 32-bit register, we emit a "mov", but currently report the cost of the "mov" incorrectly. In terms of speed, we currently say the cost is that of an extend operation. But the cost of a "mov" is the cost of 1 instruction, so fix that. In terms of size, we currently say that the "mov" takes 0 instructions. Fix it by changing it to 1. Bootstrapped and tested on aarch64-none-elf. gcc/ * config/aarch64/aarch64.c (aarch64_rtx_costs): Fix cost of zero extend. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@238820 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 16db0abc1058..6945af979563 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2016-07-28 Kristina Martsenko + + * config/aarch64/aarch64.c (aarch64_rtx_costs): Fix cost of zero extend. + 2016-07-28 Wilco Dijkstra * config/aarch64/aarch64.c (aarch64_pushwb_pair_reg): Rename. diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index d456670b7fe9..e91811d2cae6 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -6803,11 +6803,12 @@ cost_plus: { int op_cost = rtx_cost (op0, VOIDmode, ZERO_EXTEND, 0, speed); - if (!op_cost && speed) - /* MOV. */ - *cost += extra_cost->alu.extend; - else - /* Free, the cost is that of the SI mode operation. */ + /* If OP_COST is non-zero, then the cost of the zero extend + is effectively the cost of the inner operation. Otherwise + we have a MOV instruction and we take the cost from the MOV + itself. This is true independently of whether we are + optimizing for space or time. */ + if (op_cost) *cost = op_cost; return true;