From: Dimitrios Apostolou <jimis@gmx.net>
To: Dimitrios Apostolou <jimis@gmx.net>
Cc: gcc-patches@gcc.gnu.org, Steven Bosscher <stevenb.gcc@gmail.com>,
christophe.jaillet@wanadoo.fr
Subject: cse.c: preferable()
Date: Mon, 22 Aug 2011 09:50:00 -0000 [thread overview]
Message-ID: <alpine.LNX.2.02.1108221129520.1374@localhost.localdomain> (raw)
In-Reply-To: <alpine.LNX.2.02.1108221001330.1374@localhost.localdomain>
[-- Attachment #1: Type: TEXT/PLAIN, Size: 350 bytes --]
Attached patch is also posted at bug #19832 and I think resolves it, as
well as /maybe/ offers a negligible speedup of 3-4 M instr or a couple
milliseconds. I also post it here for comments.
2011-08-13 Dimitrios Apostolou <jimis@gmx.net>
* cse.c (preferable): Make it more readable and slightly faster,
without affecting its logic.
[-- Attachment #2: Type: TEXT/plain, Size: 1585 bytes --]
=== modified file 'gcc/cse.c'
--- gcc/cse.c 2011-06-02 21:52:46 +0000
+++ gcc/cse.c 2011-08-13 00:54:06 +0000
@@ -720,32 +720,25 @@ approx_reg_cost (rtx x)
static int
preferable (int cost_a, int regcost_a, int cost_b, int regcost_b)
{
- /* First, get rid of cases involving expressions that are entirely
- unwanted. */
- if (cost_a != cost_b)
- {
- if (cost_a == MAX_COST)
- return 1;
- if (cost_b == MAX_COST)
- return -1;
- }
+ int cost_diff = cost_a - cost_b;
+ int regcost_diff = regcost_a - regcost_b;
- /* Avoid extending lifetimes of hardregs. */
- if (regcost_a != regcost_b)
+ if (cost_diff != 0)
{
- if (regcost_a == MAX_COST)
- return 1;
- if (regcost_b == MAX_COST)
- return -1;
+ /* If none of the expressions are entirely unwanted */
+ if ((cost_a != MAX_COST) && (cost_b != MAX_COST)
+ /* AND only one of the regs is HARD_REG */
+ && (regcost_diff != 0)
+ && ((regcost_a == MAX_COST) || (regcost_b == MAX_COST))
+ )
+ /* Then avoid extending lifetime of HARD_REG */
+ return regcost_diff;
+
+ return cost_diff;
}
- /* Normal operation costs take precedence. */
- if (cost_a != cost_b)
- return cost_a - cost_b;
- /* Only if these are identical consider effects on register pressure. */
- if (regcost_a != regcost_b)
- return regcost_a - regcost_b;
- return 0;
+ /* cost_a == costb, consider effects on register pressure */
+ return regcost_diff;
}
/* Internal function, to compute cost when X is not a register; called
prev parent reply other threads:[~2011-08-22 8:37 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-22 7:50 Various minor speed-ups Dimitrios Apostolou
2011-08-22 7:53 ` graphds.[ch]: alloc_pool for edges Dimitrios Apostolou
2011-08-22 8:46 ` Jakub Jelinek
2011-08-22 10:11 ` Richard Guenther
2011-08-22 7:53 ` mem_attrs_htab Dimitrios Apostolou
2011-08-22 8:37 ` mem_attrs_htab Jakub Jelinek
2011-08-22 9:39 ` mem_attrs_htab Dimitrios Apostolou
2011-08-22 9:43 ` mem_attrs_htab Jakub Jelinek
2011-08-22 10:45 ` mem_attrs_htab Richard Guenther
2011-08-22 11:11 ` mem_attrs_htab Jakub Jelinek
2011-08-22 11:54 ` mem_attrs_htab Richard Guenther
2011-08-22 16:13 ` mem_attrs_htab Michael Matz
2011-08-22 7:59 ` tree-ssa*: reduce malloc() calls by preallocating hot VECs on the stack Dimitrios Apostolou
2011-08-22 10:07 ` Richard Guenther
2011-08-22 8:05 ` tree-ssa-structalias.c: alloc_pool for struct equiv_class_label Dimitrios Apostolou
2011-08-22 9:01 ` Dimitrios Apostolou
2011-08-22 10:25 ` Richard Guenther
2011-08-22 11:26 ` Dimitrios Apostolou
2011-08-22 8:43 ` Various minor speed-ups Dimitrios Apostolou
2011-08-22 11:01 ` Richard Guenther
2011-08-22 9:44 ` Dimitrios Apostolou
2011-08-22 9:50 ` Dimitrios Apostolou [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LNX.2.02.1108221129520.1374@localhost.localdomain \
--to=jimis@gmx.net \
--cc=christophe.jaillet@wanadoo.fr \
--cc=gcc-patches@gcc.gnu.org \
--cc=stevenb.gcc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).