From: Bin Cheng <Bin.Cheng@arm.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: nd <nd@arm.com>
Subject: [PATCH PR71347][Partial revert r235513]Compute cost for all uses in group
Date: Mon, 13 Jun 2016 09:57:00 -0000 [thread overview]
Message-ID: <DB5PR08MB1144BCACC3F137372BAC7A63E7530@DB5PR08MB1144.eurprd08.prod.outlook.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 701 bytes --]
Hi,
This patch partially reverts part of r235513 to fix PR71347, the original patch is to improve compilation time for a small amount. Root cause as analyzed in bugzilla PR is that we can't skip computing cost for sub iv_use if it has different position to the first use in group. The patch also includes a new test.
Bootstrap and test on x86_64. Is it OK?
Thanks,
bin
2016-05-31 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/71347
* tree-ssa-loop-ivopts.c (determine_group_iv_cost_address): Compute
cost for all uses in group.
gcc/testsuite/ChangeLog
2016-05-31 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/71347
* gcc.dg/tree-ssa/pr71347.c: New test.
[-- Attachment #2: pr71347-20160531.txt --]
[-- Type: text/plain, Size: 2540 bytes --]
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 1e8d637..25b9780 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -5115,7 +5115,7 @@ determine_group_iv_cost_address (struct ivopts_data *data,
{
unsigned i;
bitmap depends_on;
- bool can_autoinc, first = true;
+ bool can_autoinc;
iv_inv_expr_ent *inv_expr = NULL;
struct iv_use *use = group->vuses[0];
comp_cost sum_cost = no_cost, cost;
@@ -5142,30 +5142,11 @@ determine_group_iv_cost_address (struct ivopts_data *data,
{
struct iv_use *next = group->vuses[i];
- /* Compute cost for the first use with different offset to the main
- use and add it afterwards. Costs for these uses could be quite
- different. Given below uses in a group:
- use 0 : {base + A + offset_0, step}
- use 0.1: {base + A + offset_0, step}
- use 0.2: {base + A + offset_1, step}
- use 0.3: {base + A + offset_2, step}
- when we need to compute costs with candidate:
- cand 1 : {base + B + offset_0, step}
-
- The first use with different offset is use 0.2, its cost is larger
- than cost of use 0/0.1 because we need to compute:
- A - B + offset_1 - offset_0
- rather than:
- A - B. */
- if (first && next->addr_offset != use->addr_offset)
- {
- first = false;
- cost = get_computation_cost (data, next, cand, true,
- NULL, &can_autoinc, NULL);
- /* Remove setup cost. */
- if (!cost.infinite_cost_p ())
- cost -= cost.scratch;
- }
+ /* TODO: We could skip computing cost for sub iv_use when it has the
+ same cost as the first iv_use, but the cost really depends on the
+ offset and where the iv_use is. */
+ cost = get_computation_cost (data, next, cand, true,
+ NULL, &can_autoinc, NULL);
sum_cost += cost;
}
set_group_iv_cost (data, group, cand, sum_cost, depends_on,
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr71347.c b/gcc/testsuite/gcc.dg/tree-ssa/pr71347.c
new file mode 100644
index 0000000..7e5ad49
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr71347.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+double in;
+extern void Write (double);
+void foo (void)
+{
+ static double X[9];
+ int i;
+ X[1] = in * in;
+ for (i = 2; i <= 8; i++)
+ X[i] = X[i - 1] * X[1];
+ Write (X[5]);
+}
+
+/* Load of X[i - i] can be omitted by reusing X[i] in previous iteration. */
+/* { dg-final { scan-tree-dump-not ".* = MEM.*;" "optimized"} } */
next reply other threads:[~2016-06-13 9:57 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-13 9:57 Bin Cheng [this message]
2016-06-13 10:10 ` Richard Biener
2016-06-18 8:59 ` Andreas Schwab
2016-06-20 8:18 ` Christophe Lyon
2016-06-20 8:20 ` Bin.Cheng
2016-06-20 9:11 ` Bin.Cheng
2016-06-20 9:19 ` Andreas Schwab
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=DB5PR08MB1144BCACC3F137372BAC7A63E7530@DB5PR08MB1144.eurprd08.prod.outlook.com \
--to=bin.cheng@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=nd@arm.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).