+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
+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
--- /dev/null
+/* 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" } } */
--- /dev/null
+/* 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" } } */
--- /dev/null
+/* 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" } } */
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,
{
/* 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)
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)