Commit 6a114766 by Jan Sjodin Committed by Sebastian Pop

re PR middle-end/38492 ([graphite] segfaulting code when compiled with…

re PR middle-end/38492 ([graphite] segfaulting code when compiled with -fgraphite -fgraphite-identity)

2009-01-07  Jan Sjodin  <jan.sjodin@amd.com>

	PR tree-optimization/38492
	PR tree-optimization/38498
	* tree-check.c (operator_is_linear, scev_is_linear_expression): New.
	* tree-chrec.h (scev_is_linear_expression): Declared.
	* graphite.c (graphite_cannot_represent_loop_niter): New.
	(scopdet_basic_block_info): Call graphite_cannot_represent_loop_niter.
	(graphite_loop_normal_form): Use gcc_assert.
	(scan_tree_for_params): Use CASE_CONVERT.
	(phi_node_is_iv, bb_contains_non_iv_scalar_phi_nodes): New.
	(build_scop_conditions_1): Call bb_contains_non_iv_scalar_phi_nodes.
	Use gcc_assert.  Discard scops that contain unhandled cases.
	(build_scop_conditions): Return a boolean status for unhandled cases.
	(strip_mine_profitable_p): Print the loop number, not its depth.
	(is_interchange_valid): Pass the depth of the loop nest, don't
	recompute it wrongly.
	(graphite_trans_bb_block): Same.
	(graphite_trans_bb_block): Print tentative of loop blocking.
	(graphite_trans_scop_block): Do not print that the loop has been
	blocked.
	(graphite_transform_loops): Do not handle scops that contain condition
	scalar phi nodes.

	* testsuite/gcc.dg/graphite/pr38500.c: Fixed warning as committed
	in trunk.
	* testsuite/gcc.dg/graphite/block-0.c: Update test.
	* testsuite/gcc.dg/graphite/block-1.c: Same.
	* testsuite/gcc.dg/graphite/block-2.c: Remove xfail and test for blocking.
	* testsuite/gcc.dg/graphite/block-4.c: Remove test for strip mine.
	* testsuite/gcc.dg/graphite/block-3.c: New.
	* testsuite/gcc.dg/graphite/pr38498.c: New.

From-SVN: r143159
parent 65b82caa
2009-01-07 Jan Sjodin <jan.sjodin@amd.com>
PR tree-optimization/38492
PR tree-optimization/38498
* tree-check.c (operator_is_linear, scev_is_linear_expression): New.
* tree-chrec.h (scev_is_linear_expression): Declared.
* graphite.c (graphite_cannot_represent_loop_niter): New.
(scopdet_basic_block_info): Call graphite_cannot_represent_loop_niter.
(graphite_loop_normal_form): Use gcc_assert.
(scan_tree_for_params): Use CASE_CONVERT.
(phi_node_is_iv, bb_contains_non_iv_scalar_phi_nodes): New.
(build_scop_conditions_1): Call bb_contains_non_iv_scalar_phi_nodes.
Use gcc_assert. Discard scops that contain unhandled cases.
(build_scop_conditions): Return a boolean status for unhandled cases.
(strip_mine_profitable_p): Print the loop number, not its depth.
(is_interchange_valid): Pass the depth of the loop nest, don't
recompute it wrongly.
(graphite_trans_bb_block): Same.
(graphite_trans_bb_block): Print tentative of loop blocking.
(graphite_trans_scop_block): Do not print that the loop has been
blocked.
(graphite_transform_loops): Do not handle scops that contain condition
scalar phi nodes.
2009-01-07 H.J. Lu <hongjiu.lu@intel.com> 2009-01-07 H.J. Lu <hongjiu.lu@intel.com>
AVX Programming Reference (December, 2008) AVX Programming Reference (December, 2008)
......
2009-01-07 Jan Sjodin <jan.sjodin@amd.com>
PR tree-optimization/38492
PR tree-optimization/38498
* testsuite/gcc.dg/graphite/pr38500.c: Fixed warning as committed
in trunk.
* testsuite/gcc.dg/graphite/block-0.c: Update test.
* testsuite/gcc.dg/graphite/block-1.c: Same.
* testsuite/gcc.dg/graphite/block-2.c: Remove xfail and test for blocking.
* testsuite/gcc.dg/graphite/block-4.c: Remove test for strip mine.
* testsuite/gcc.dg/graphite/block-3.c: New.
* testsuite/gcc.dg/graphite/pr38498.c: New.
2009-01-07 H.J. Lu <hongjiu.lu@intel.com> 2009-01-07 H.J. Lu <hongjiu.lu@intel.com>
AVX Programming Reference (December, 2008) AVX Programming Reference (December, 2008)
......
...@@ -21,5 +21,5 @@ main() ...@@ -21,5 +21,5 @@ main()
return toto(); return toto();
} }
/* { dg-final { scan-tree-dump-times "Loop blocked" 1 "graphite"} } */ /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */
...@@ -36,5 +36,5 @@ int main() ...@@ -36,5 +36,5 @@ int main()
return sum; return sum;
} }
/* { dg-final { scan-tree-dump-times "Loop blocked" 2 "graphite"} } */ /* { dg-final { scan-tree-dump-times "will be loop blocked" 2 "graphite"} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */
...@@ -28,5 +28,4 @@ void fallbackSort ( UInt32* fmap, ...@@ -28,5 +28,4 @@ void fallbackSort ( UInt32* fmap,
} }
AssertH ( j < 256, 1005 ); AssertH ( j < 256, 1005 );
} }
/* { dg-final { scan-tree-dump-times "Loop blocked" 1 "graphite" { xfail *-*-* }} } */
/* { dg-final { cleanup-tree-dump "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */
/* { dg-options "-O2 -floop-block -fdump-tree-graphite-all" } */
#define N 24
#define M 1000
float A[1000][1000][1000], B[1000][1000], C[1000][1000];
void test (void)
{
int i, j, k;
/* These loops contain too few iterations for being strip-mined by 64. */
for (i = 0; i < 24; i++)
for (j = 0; j < 24; j++)
for (k = 0; k < 24; k++)
A[i][j][k] = B[i][k] * C[k][j];
/* These loops should still be strip mined. */
for (i = 0; i < 1000; i++)
for (j = 0; j < 1000; j++)
for (k = 0; k < 1000; k++)
A[i][j][k] = B[i][k] * C[k][j];
}
/* { dg-final { cleanup-tree-dump "graphite" } } */
...@@ -9,18 +9,15 @@ void test (void) ...@@ -9,18 +9,15 @@ void test (void)
{ {
int i, j, k; int i, j, k;
/* These loops contain too few iterations for being strip-mined by 64. */
for (i = 0; i < 24; i++) for (i = 0; i < 24; i++)
for (j = 0; j < 24; j++) for (j = 0; j < 24; j++)
for (k = 0; k < 24; k++) for (k = 0; k < 24; k++)
A[i][j] = B[i][k] * C[k][j]; A[i][j] = B[i][k] * C[k][j];
/* These loops should still be strip mined. */
for (i = 0; i < 1000; i++) for (i = 0; i < 1000; i++)
for (j = 0; j < 1000; j++) for (j = 0; j < 1000; j++)
for (k = 0; k < 1000; k++) for (k = 0; k < 1000; k++)
A[i][j] = B[i][k] * C[k][j]; A[i][j] = B[i][k] * C[k][j];
} }
/* { dg-final { scan-tree-dump-times "Strip Mining is not profitable" 2 "graphite" } } */
/* { dg-final { cleanup-tree-dump "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */
/* { dg-options "-O2 -floop-block" } */
double test_vector (float **data, int rows, int cols, int vqrows,double epsilon, int maxiter,int **mean, int *map)
{
int i, j, r, it;
double sqerr, prev_sqerr=0, t;
unsigned int *sel;
int *count;
for (it = 0;; it++)
{
if ((sqerr == 0.0) || (it >= maxiter-1) ||((it > 0) && ( ((prev_sqerr - sqerr) / prev_sqerr) < epsilon )) )
for (i = 0; i < vqrows; i++)
{
for (j = 0; j < cols; j++)
mean[i][j] = 0.0;
count[i] = 0;
}
}
}
...@@ -1430,3 +1430,64 @@ for_each_scev_op (tree *scev, bool (*cbck) (tree *, void *), void *data) ...@@ -1430,3 +1430,64 @@ for_each_scev_op (tree *scev, bool (*cbck) (tree *, void *), void *data)
} }
} }
/* Returns true when the operation can be part of a linear
expression. */
static inline bool
operator_is_linear (tree scev)
{
switch (TREE_CODE (scev))
{
case INTEGER_CST:
case POLYNOMIAL_CHREC:
case PLUS_EXPR:
case POINTER_PLUS_EXPR:
case MULT_EXPR:
case MINUS_EXPR:
case NEGATE_EXPR:
case SSA_NAME:
case NON_LVALUE_EXPR:
CASE_CONVERT:
return true;
default:
return false;
}
}
/* Return true when SCEV is a linear expression. Linear expressions
can contain additions, substractions and multiplications.
Multiplications are restricted to constant scaling: "cst * x". */
bool
scev_is_linear_expression (tree scev)
{
if (scev == NULL
|| !operator_is_linear (scev))
return false;
if (TREE_CODE (scev) == MULT_EXPR)
return !(tree_contains_chrecs (TREE_OPERAND (scev, 0), NULL)
&& tree_contains_chrecs (TREE_OPERAND (scev, 1), NULL));
switch (TREE_CODE_LENGTH (TREE_CODE (scev)))
{
case 3:
return scev_is_linear_expression (TREE_OPERAND (scev, 0))
&& scev_is_linear_expression (TREE_OPERAND (scev, 1))
&& scev_is_linear_expression (TREE_OPERAND (scev, 2));
case 2:
return scev_is_linear_expression (TREE_OPERAND (scev, 0))
&& scev_is_linear_expression (TREE_OPERAND (scev, 1));
case 1:
return scev_is_linear_expression (TREE_OPERAND (scev, 0));
case 0:
return true;
default:
return false;
}
}
...@@ -84,6 +84,7 @@ extern bool evolution_function_is_affine_multivariate_p (const_tree, int); ...@@ -84,6 +84,7 @@ extern bool evolution_function_is_affine_multivariate_p (const_tree, int);
extern bool evolution_function_is_univariate_p (const_tree); extern bool evolution_function_is_univariate_p (const_tree);
extern unsigned nb_vars_in_chrec (tree); extern unsigned nb_vars_in_chrec (tree);
extern bool evolution_function_is_invariant_p (tree, int); extern bool evolution_function_is_invariant_p (tree, int);
extern bool scev_is_linear_expression (tree);
/* Determines whether CHREC is equal to zero. */ /* Determines whether CHREC is equal to zero. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment