Comment 0 for bug 960283

Revision history for this message
mickael guene (mickael-guene) wrote :

When compiling attached small.c file with linaro-4.6-2012.03 configured with --enable-checking and gcc options :
gcc -c small.c -msoft-float -march=armv7-a -mfloat-abi=softfp -mfpu=neon -mvectorize-with-neon-quad -ftree-vectorize -O2

I have a great number of assertion due to access to unallocated memory.
patch from Bug #960274 plus attached patch fix them all (certainly badly)

I have not done a very deep analysis but either analysis pass make a wrong decision when applying slp optimization or
code is seriously bugged.

diff -Naur sources/gcc/tree-vect-slp.c sources.patch/gcc/tree-vect-slp.c
--- sources/gcc/tree-vect-slp.c 2012-03-12 12:31:42.000000000 +0100
+++ sources.patch/gcc/tree-vect-slp.c 2012-03-20 13:36:46.000000000 +0100
@@ -2450,7 +2450,7 @@
         }

       /* Allocate memory for vectorized defs. */
- vec_defs = VEC_alloc (tree, heap, number_of_vects);
+ vec_defs = VEC_alloc (tree, heap, number_of_vects + 1);

       /* For reduction defs we call vect_get_constant_vectors (), since we are
          looking for initial loop invariant values. */
@@ -2827,7 +2827,7 @@

   if (!SLP_TREE_VEC_STMTS (node))
     {
- SLP_TREE_VEC_STMTS (node) = VEC_alloc (gimple, heap, vec_stmts_size);
+ SLP_TREE_VEC_STMTS (node) = VEC_alloc (gimple, heap, vec_stmts_size + 1);
       SLP_TREE_NUMBER_OF_VEC_STMTS (node) = vec_stmts_size;
     }

diff -Naur sources/gcc/tree-vect-stmts.c sources.patch/gcc/tree-vect-stmts.c
--- sources/gcc/tree-vect-stmts.c 2012-03-12 12:31:42.000000000 +0100
+++ sources.patch/gcc/tree-vect-stmts.c 2012-03-20 15:14:28.000000000 +0100
@@ -2954,7 +2954,7 @@
       FOR_EACH_VEC_ELT (tree, vec_oprnds0, i, vop0)
         {
    vop1 = ((op_type == binary_op || op_type == ternary_op)
- ? VEC_index (tree, vec_oprnds1, i) : NULL_TREE);
+ ? ((i < VEC_length(tree, vec_oprnds1))?VEC_index (tree, vec_oprnds1, i) : VEC_index (tree, vec_oprnds1, VEC_length(tree, vec_oprnds1) - 1)) : NULL_TREE);
    vop2 = ((op_type == ternary_op)
     ? VEC_index (tree, vec_oprnds2, i) : NULL_TREE);
    new_stmt = gimple_build_assign_with_ops3 (code, vec_dest,