From: Tom de Vries <vries@codesourcery.com>
To: Zdenek Dvorak <rakdver@kam.mff.cuni.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH, PR45098, 9/10]
Date: Tue, 17 May 2011 10:03:00 -0000 [thread overview]
Message-ID: <4DD2223A.4040309@codesourcery.com> (raw)
In-Reply-To: <4DD21F6E.4050308@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 542 bytes --]
On 05/17/2011 09:10 AM, Tom de Vries wrote:
> Hi Zdenek,
>
> I have a patch set for for PR45098.
>
> 01_object-size-target.patch
> 02_pr45098-rtx-cost-set.patch
> 03_pr45098-computation-cost.patch
> 04_pr45098-iv-init-cost.patch
> 05_pr45098-bound-cost.patch
> 06_pr45098-bound-cost.test.patch
> 07_pr45098-nowrap-limits-iterations.patch
> 08_pr45098-nowrap-limits-iterations.test.patch
> 09_pr45098-shift-add-cost.patch
> 10_pr45098-shift-add-cost.test.patch
>
> I will sent out the patches individually.
>
OK for trunk?
Thanks,
- Tom
[-- Attachment #2: 09_pr45098-shift-add-cost.patch --]
[-- Type: text/x-patch, Size: 2834 bytes --]
2011-05-05 Tom de Vries <tom@codesourcery.com>
PR target/45098
* tree-ssa-loop-ivopts.c: Include expmed.h.
(get_shiftadd_cost): New function.
(force_expr_to_var_cost): Use get_shiftadd_cost.
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c (revision 173380)
+++ gcc/tree-ssa-loop-ivopts.c (working copy)
@@ -92,6 +92,12 @@ along with GCC; see the file COPYING3.
#include "tree-inline.h"
#include "tree-ssa-propagate.h"
+/* FIXME: add_cost and zero_cost defined in exprmed.h conflict with local uses.
+ */
+#include "expmed.h"
+#undef add_cost
+#undef zero_cost
+
/* FIXME: Expressions are expanded to RTL in this pass to determine the
cost of different addressing modes. This should be moved to a TBD
interface between the GIMPLE and RTL worlds. */
@@ -3504,6 +3510,37 @@ get_address_cost (bool symbol_present, b
return new_cost (cost + acost, complexity);
}
+ /* Calculate the SPEED or size cost of shiftadd EXPR in MODE. MULT is the
+ the EXPR operand holding the shift. COST0 and COST1 are the costs for
+ calculating the operands of EXPR. Returns true if successful, and returns
+ the cost in COST. */
+
+static bool
+get_shiftadd_cost (tree expr, enum machine_mode mode, comp_cost cost0,
+ comp_cost cost1, tree mult, bool speed, comp_cost *cost)
+{
+ comp_cost res;
+ tree op1 = TREE_OPERAND (expr, 1);
+ tree cst = TREE_OPERAND (mult, 1);
+ int m = exact_log2 (int_cst_value (cst));
+ int maxm = MIN (BITS_PER_WORD, GET_MODE_BITSIZE (mode));
+ int sa_cost;
+
+ if (!(m >= 0 && m < maxm))
+ return false;
+
+ sa_cost = (TREE_CODE (expr) != MINUS_EXPR
+ ? shiftadd_cost[speed][mode][m]
+ : (mult == op1
+ ? shiftsub1_cost[speed][mode][m]
+ : shiftsub0_cost[speed][mode][m]));
+ res = new_cost (sa_cost, 0);
+ res = add_costs (res, mult == op1 ? cost0 : cost1);
+
+ *cost = res;
+ return true;
+}
+
/* Estimates cost of forcing expression EXPR into a variable. */
static comp_cost
@@ -3629,6 +3666,21 @@ force_expr_to_var_cost (tree expr, bool
case MINUS_EXPR:
case NEGATE_EXPR:
cost = new_cost (add_cost (mode, speed), 0);
+ if (TREE_CODE (expr) != NEGATE_EXPR)
+ {
+ tree mult = NULL_TREE;
+ comp_cost sa_cost;
+ if (TREE_CODE (op1) == MULT_EXPR)
+ mult = op1;
+ else if (TREE_CODE (op0) == MULT_EXPR)
+ mult = op0;
+
+ if (mult != NULL_TREE
+ && TREE_CODE (TREE_OPERAND (mult, 1)) == INTEGER_CST
+ && get_shiftadd_cost (expr, mode, cost0, cost1, mult, speed,
+ &sa_cost))
+ return sa_cost;
+ }
break;
case MULT_EXPR:
next prev parent reply other threads:[~2011-05-17 7:23 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-17 7:23 [PATCH, PR45098] Tom de Vries
2011-05-17 7:25 ` [PATCH, PR45098, 1/10] Tom de Vries
2011-05-19 11:17 ` [PATCH PR45098, 1/10] Proc object-size fix Tom de Vries
2011-05-17 8:12 ` [PATCH, PR45098, 2/10] Tom de Vries
2011-05-18 9:39 ` Zdenek Dvorak
2011-05-17 8:30 ` [PATCH, PR45098, 3/10] Tom de Vries
2011-05-18 10:10 ` Zdenek Dvorak
2011-05-18 13:00 ` Tom de Vries
[not found] ` <20110518152457.GA13360@kam.mff.cuni.cz>
2011-05-18 19:30 ` Tom de Vries
2011-05-17 8:32 ` [PATCH, PR45098, 4/10] Tom de Vries
2011-05-18 17:46 ` [PATCH PR45098, 4/10] Iv init cost Tom de Vries
2011-05-18 22:59 ` Zdenek Dvorak
2011-05-25 14:20 ` Richard Sandiford
2011-05-26 12:24 ` Tom de Vries
2011-05-31 15:22 ` Richard Sandiford
2011-05-17 8:37 ` [PATCH, PR45098, 5/10] Tom de Vries
2011-05-18 17:48 ` [PATCH PR45098, 5/10] Bound cost Tom de Vries
2011-05-19 4:45 ` Zdenek Dvorak
2011-05-17 8:42 ` [PATCH, PR45098, 6/10] Tom de Vries
2011-05-18 17:48 ` [PATCH PR45098, 6/10] Bound cost - test cases Tom de Vries
2011-05-17 8:58 ` [PATCH, PR45098, 7/10] Tom de Vries
2011-05-18 17:52 ` [PATCH PR45098, 7/10] Nowrap limits iterations Tom de Vries
2011-05-19 4:45 ` Zdenek Dvorak
2011-05-20 12:22 ` Tom de Vries
2011-05-21 18:54 ` Zdenek Dvorak
2011-05-21 22:53 ` Tom de Vries
2011-05-28 17:58 ` Tom de Vries
2011-05-30 15:12 ` Zdenek Dvorak
2011-05-31 9:07 ` Tom de Vries
2011-05-31 9:11 ` Zdenek Dvorak
2011-06-11 10:13 ` Tom de Vries
2011-06-12 1:17 ` Zdenek Dvorak
2011-05-23 14:50 ` H.J. Lu
2011-05-17 9:03 ` [PATCH, PR45098, 8/10] Tom de Vries
2011-05-18 18:23 ` [PATCH PR45098, 8/10] Nowrap limits iterations - test cases Tom de Vries
2011-05-18 18:27 ` [PATCH PR45098, 9/10] Cheap shift-add Tom de Vries
2011-05-19 5:33 ` Zdenek Dvorak
2011-05-20 11:32 ` Tom de Vries
2011-05-20 20:09 ` Zdenek Dvorak
2011-05-21 15:05 ` Eric Botcazou
2011-05-22 19:33 ` Tom de Vries
2011-05-22 20:22 ` Richard Guenther
2011-05-22 21:11 ` Eric Botcazou
2011-05-17 10:03 ` Tom de Vries [this message]
2011-05-17 10:30 ` [PATCH, PR45098, 10/10] Tom de Vries
2011-05-18 18:30 ` [PATCH PR45098, 10/10] Cheap shift-add - test case Tom de Vries
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=4DD2223A.4040309@codesourcery.com \
--to=vries@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rakdver@kam.mff.cuni.cz \
/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).