summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-10 02:35:19 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-10 02:35:19 +0000
commit958b3c8ac82ed1a8c30d505430babba40a3e132e (patch)
treec179f7d98e8b98e288509bbe8a5cf077dada2455
parenta25b333d8554e5937be5adc417f6300d4d62f1e4 (diff)
downloadgcc-958b3c8ac82ed1a8c30d505430babba40a3e132e.tar.gz
PR tree-optimization/40436
* ipa-inline.c (leaf_node_p): Implement using is_inexpensive_builtin. * tree-inline.c (estimate_num_insns): Inexpensive builtins are like normal instructions; be sure bultin is not implemented in this file; compute non-zero return cost. (init_inline_once): Reduce builtin_call_cost to 1; set return cost. * tree-inline.h (eni_weights_d): Add return cost. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166517 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/ipa-inline.c7
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/i386/recip-vec-sqrtf-avx.c3
-rw-r--r--gcc/tree-inline.c18
-rw-r--r--gcc/tree-inline.h3
6 files changed, 36 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f602a02a36c..0f219668d61 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2010-11-09 Jan Hubicka <jh@suse.cz>
+
+ PR tree-optimization/40436
+ * ipa-inline.c (leaf_node_p): Implement using is_inexpensive_builtin.
+ * tree-inline.c (estimate_num_insns): Inexpensive builtins are like
+ normal instructions; be sure bultin is not implemented in this file;
+ compute non-zero return cost.
+ (init_inline_once): Reduce builtin_call_cost to 1; set return cost.
+ * tree-inline.h (eni_weights_d): Add return cost.
+
2010-11-09 Joseph Myers <joseph@codesourcery.com>
* c-parser.c (c_parser_struct_declaration): Handle declaration
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 7241dcb0d48..0072d61bfc3 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -1578,16 +1578,15 @@ cgraph_decide_inlining (void)
return 0;
}
-/* Return true when N is leaf function. Accept cheap (pure&const) builtins
+/* Return true when N is leaf function. Accept cheap builtins
in leaf functions. */
+
static bool
leaf_node_p (struct cgraph_node *n)
{
struct cgraph_edge *e;
for (e = n->callees; e; e = e->next_callee)
- if (!DECL_BUILT_IN (e->callee->decl)
- || (!TREE_READONLY (e->callee->decl)
- || DECL_PURE_P (e->callee->decl)))
+ if (!is_inexpensive_builtin (e->callee->decl))
return false;
return true;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 651e921278b..e4cb4365347 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2010-11-09 Jan Hubicka <jh@suse.cz>
+
+ * testsuite/gcc.target/i386/recip-vec-sqrtf-avx.c: Update for loop unrolling.
+
2010-11-09 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/struct-semi-4.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/recip-vec-sqrtf-avx.c b/gcc/testsuite/gcc.target/i386/recip-vec-sqrtf-avx.c
index 6591c12d2c6..506df88f956 100644
--- a/gcc/testsuite/gcc.target/i386/recip-vec-sqrtf-avx.c
+++ b/gcc/testsuite/gcc.target/i386/recip-vec-sqrtf-avx.c
@@ -31,4 +31,5 @@ void t3(void)
r[i] = sqrtf (a[i]);
}
-/* { dg-final { scan-assembler-times "vrsqrtps\[ \\t\]+\[^\n\]*%ymm" 3 } } */
+/* Last loop is small enough to be fully unrolled. */
+/* { dg-final { scan-assembler-times "vrsqrtps\[ \\t\]+\[^\n\]*%ymm" 4 } } */
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 88806beddd3..fc470a7637e 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -3484,10 +3484,16 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
if (POINTER_TYPE_P (funtype))
funtype = TREE_TYPE (funtype);
- if (is_simple_builtin (decl))
+ /* Do not special case builtins where we see the body.
+ This just confuse inliner. */
+ if (!decl || cgraph_node (decl)->analyzed)
+ cost = weights->call_cost;
+ /* For buitins that are likely expanded to nothing or
+ inlined do not account operand costs. */
+ else if (is_simple_builtin (decl))
return 0;
else if (is_inexpensive_builtin (decl))
- cost = weights->target_builtin_call_cost;
+ return weights->target_builtin_call_cost;
else
cost = weights->call_cost;
@@ -3536,11 +3542,13 @@ estimate_num_insns (gimple stmt, eni_weights *weights)
break;
}
+ case GIMPLE_RETURN:
+ return weights->return_cost;
+
case GIMPLE_GOTO:
case GIMPLE_LABEL:
case GIMPLE_NOP:
case GIMPLE_PHI:
- case GIMPLE_RETURN:
case GIMPLE_PREDICT:
case GIMPLE_DEBUG:
return 0;
@@ -3640,16 +3648,18 @@ init_inline_once (void)
eni_size_weights.div_mod_cost = 1;
eni_size_weights.omp_cost = 40;
eni_size_weights.time_based = false;
+ eni_size_weights.return_cost = 1;
/* Estimating time for call is difficult, since we have no idea what the
called function does. In the current uses of eni_time_weights,
underestimating the cost does less harm than overestimating it, so
we choose a rather small value here. */
eni_time_weights.call_cost = 10;
- eni_time_weights.target_builtin_call_cost = 10;
+ eni_time_weights.target_builtin_call_cost = 1;
eni_time_weights.div_mod_cost = 10;
eni_time_weights.omp_cost = 40;
eni_time_weights.time_based = true;
+ eni_time_weights.return_cost = 2;
}
/* Estimate the number of instructions in a gimple_seq. */
diff --git a/gcc/tree-inline.h b/gcc/tree-inline.h
index a8a33aa84d9..fa0353735a7 100644
--- a/gcc/tree-inline.h
+++ b/gcc/tree-inline.h
@@ -144,6 +144,9 @@ typedef struct eni_weights_d
/* Cost for omp construct. */
unsigned omp_cost;
+ /* Cost of return. */
+ unsigned return_cost;
+
/* True when time of statemnt should be estimated. Thus i.e
cost of switch statement is logarithmic rather than linear in number
of cases. */