re PR tree-optimization/57741 (ICE in tree.c:build_int_cst_wide starting in revision 200394)

PR tree-optimization/57741
	* tree-vect-loop.c (vect_is_simple_iv_evolution): Disallow
	non-INTEGRAL_TYPE_P non-SCALAR_FLOAT_TYPE_P SSA_NAME step_exprs,
	or SCALAR_FLOAT_TYPE_P SSA_NAMEs if !flag_associative_math.
	Allow REAL_CST step_exprs if flag_associative_math.
	(get_initial_def_for_induction): Handle SCALAR_FLOAT_TYPE_P step_expr.

	* gcc.dg/vect/pr57741-1.c: New test.
	* gcc.dg/vect/pr57741-2.c: New test.
	* gcc.dg/vect/pr57741-3.c: New test.

From-SVN: r200600
This commit is contained in:
Jakub Jelinek 2013-07-02 13:54:09 +02:00 committed by Jakub Jelinek
parent f8411fcce9
commit c4e87a1393
6 changed files with 143 additions and 3 deletions

View file

@ -1,3 +1,12 @@
2013-07-02 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/57741
* tree-vect-loop.c (vect_is_simple_iv_evolution): Disallow
non-INTEGRAL_TYPE_P non-SCALAR_FLOAT_TYPE_P SSA_NAME step_exprs,
or SCALAR_FLOAT_TYPE_P SSA_NAMEs if !flag_associative_math.
Allow REAL_CST step_exprs if flag_associative_math.
(get_initial_def_for_induction): Handle SCALAR_FLOAT_TYPE_P step_expr.
2013-07-02 Ian Bolton <ian.bolton@arm.com>
* config/aarch64/aarch64-simd.md (absdi2): Support abs for

View file

@ -1,3 +1,10 @@
2013-07-02 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/57741
* gcc.dg/vect/pr57741-1.c: New test.
* gcc.dg/vect/pr57741-2.c: New test.
* gcc.dg/vect/pr57741-3.c: New test.
2013-07-02 Ian Bolton <ian.bolton@arm.com>
* gcc.target/config/aarch64/insv_1.c: Update to show it doesn't work

View file

@ -0,0 +1,21 @@
/* PR tree-optimization/57741 */
/* { dg-do compile } */
void
foo (float *p, float *q, float x)
{
int i;
float f = 1.0f, g = 2.0f;
for (i = 0; i < 1024; i++)
{
*p++ = f;
f += x;
}
for (i = 0; i < 1024; i++)
{
*q++ = g;
g += 0.5f;
}
}
/* { dg-final { cleanup-tree-dump "vect" } } */

View file

@ -0,0 +1,44 @@
/* PR tree-optimization/57741 */
/* { dg-do run } */
/* { dg-additional-options "-ffast-math" } */
#include "tree-vect.h"
extern void abort (void);
__attribute__((noinline, noclone)) void
foo (float *p, float *q, float x)
{
int i;
p = (float *) __builtin_assume_aligned (p, 32);
q = (float *) __builtin_assume_aligned (q, 32);
float f = 1.0f, g = 2.0f;
for (i = 0; i < 1024; i++)
{
*p++ = f;
f += x;
}
for (i = 0; i < 1024; i++)
{
*q++ = g;
g += 0.5f;
}
}
float p[1024] __attribute__((aligned (32))) = { 17.0f };
float q[1024] __attribute__((aligned (32))) = { 17.0f };
int
main ()
{
int i;
check_vect ();
foo (p, q, 1.5f);
for (i = 0; i < 1024; i++)
if (p[i] != 1.0f + i * 1.5f || q[i] != 2.0f + i * 0.5f)
abort ();
return 0;
}
/* { dg-final { scan-tree-dump-times "vectorized 2 loop" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */

View file

@ -0,0 +1,42 @@
/* PR tree-optimization/57741 */
/* { dg-do run } */
/* { dg-additional-options "-ffast-math" } */
#include "tree-vect.h"
extern void abort (void);
float p[1024] __attribute__((aligned (32))) = { 17.0f };
float q[1024] __attribute__((aligned (32))) = { 17.0f };
char r[1024] __attribute__((aligned (32))) = { 1 };
__attribute__((noinline, noclone)) void
foo (float x)
{
int i;
float f = 1.0f, g = 2.0f;
for (i = 0; i < 1024; i++)
{
p[i] = f;
f += x;
q[i] = g;
g += 0.5f;
r[i]++;
}
}
int
main ()
{
int i;
check_vect ();
r[0] = 0;
foo (1.5f);
for (i = 0; i < 1024; i++)
if (p[i] != 1.0f + i * 1.5f || q[i] != 2.0f + i * 0.5f || r[i] != 1)
abort ();
return 0;
}
/* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */

View file

@ -538,7 +538,12 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tree access_fn, tree * init,
if (TREE_CODE (step_expr) != INTEGER_CST
&& (TREE_CODE (step_expr) != SSA_NAME
|| ((bb = gimple_bb (SSA_NAME_DEF_STMT (step_expr)))
&& flow_bb_inside_loop_p (get_loop (cfun, loop_nb), bb))))
&& flow_bb_inside_loop_p (get_loop (cfun, loop_nb), bb))
|| (!INTEGRAL_TYPE_P (TREE_TYPE (step_expr))
&& (!SCALAR_FLOAT_TYPE_P (TREE_TYPE (step_expr))
|| !flag_associative_math)))
&& (TREE_CODE (step_expr) != REAL_CST
|| !flag_associative_math))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
@ -3276,7 +3281,13 @@ get_initial_def_for_induction (gimple iv_phi)
{
/* iv_loop is the loop to be vectorized. Generate:
vec_step = [VF*S, VF*S, VF*S, VF*S] */
expr = build_int_cst (TREE_TYPE (step_expr), vf);
if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (step_expr)))
{
expr = build_int_cst (integer_type_node, vf);
expr = fold_convert (TREE_TYPE (step_expr), expr);
}
else
expr = build_int_cst (TREE_TYPE (step_expr), vf);
new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),
expr, step_expr);
if (TREE_CODE (step_expr) == SSA_NAME)
@ -3339,7 +3350,13 @@ get_initial_def_for_induction (gimple iv_phi)
gcc_assert (!nested_in_vect_loop);
/* Create the vector that holds the step of the induction. */
expr = build_int_cst (TREE_TYPE (step_expr), nunits);
if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (step_expr)))
{
expr = build_int_cst (integer_type_node, nunits);
expr = fold_convert (TREE_TYPE (step_expr), expr);
}
else
expr = build_int_cst (TREE_TYPE (step_expr), nunits);
new_name = fold_build2 (MULT_EXPR, TREE_TYPE (step_expr),
expr, step_expr);
if (TREE_CODE (step_expr) == SSA_NAME)