This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch, vectorizer] Fix PR tree-optimization/43074


On Tue, Feb 16, 2010 at 8:55 AM, Ira Rosen <IRAR@il.ibm.com> wrote:
>
> Hi,
>
> This patch fixes a bug in hybrid loop-aware SLP with reduction, i.e., there
> are both reduction and SLP in the same loop. The bug is in the check
> whether we have pure SLP or there are additional statements in the loop
> (vectorized with regular loop vectorization scheme). This check does not
> take into account reduction.
>
> Bootstrapped with vectorization enabled and tested on x86_64-suse-linux.
>
> The bug occurs in 4.4 as well, so I don't know if the patch is OK for 4.5?
> And for 4.4?

Yes, it's ok for both.

Thanks,
Richard.

> Thanks,
> Ira
>
> 4.5 ChangeLog:
>
> ? ? ?PR tree-optimization/43074
> ? ? ?* tree-vectorizer.h (VECTORIZABLE_CYCLE_DEF): New.
> ? ? ?* tree-vect-loop.c (vect_analyze_loop_operations): Add
> ? ? ?vectorizable cycles in hybrid SLP check.
> ? ? ?* tree-vect-slp.c (vect_detect_hybrid_slp_stmts): Likewise.
>
> testsuite/ChangeLog:
>
> ? ? ?PR tree-optimization/43074
> ? ? ?* gcc.dg/vect/fast-math-pr43074.c: New test.
>
>
> 4.4 ChangeLog:
>
> ? ? ?PR tree-optimization/43074
> ? ? ?* tree-vect-analyze.c (vect_detect_hybrid_slp_stmts): Add
> ? ? ?vectorizable cycles in hybrid SLP check.
>
> testsuite/ChangeLog:
>
> ? ? ?PR tree-optimization/43074
> ? ? ?* gcc.dg/vect/fast-math-pr43074.c: New test.
>
>
> 4.5 patch:
>
> Index: tree-vectorizer.h
> ===================================================================
> --- tree-vectorizer.h ? (revision 156769)
> +++ tree-vectorizer.h ? (working copy)
> @@ -66,6 +66,10 @@ enum vect_def_type {
> ? vect_unknown_def_type
> ?};
>
> +#define VECTORIZABLE_CYCLE_DEF(D) (((D) == vect_reduction_def) ? ? ? ? ? \
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? || ((D) == vect_double_reduction_def) \
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? || ((D) == vect_nested_cycle))
> +
> ?/* Define verbosity levels. ?*/
> ?enum verbosity_levels {
> ? REPORT_NONE,
> Index: tree-vect-loop.c
> ===================================================================
> --- tree-vect-loop.c ? ?(revision 156769)
> +++ tree-vect-loop.c ? ?(working copy)
> @@ -1184,7 +1184,10 @@ vect_analyze_loop_operations (loop_vec_i
> ? ? ? ? ?if (!vect_analyze_stmt (stmt, &need_to_vectorize, NULL))
> ? ? ? ? ? ?return false;
>
> - ? ? ? ? ?if (STMT_VINFO_RELEVANT_P (stmt_info) && !PURE_SLP_STMT
> (stmt_info))
> + ? ? ? ? ?if ((STMT_VINFO_RELEVANT_P (stmt_info)
> + ? ? ? ? ? ? ? || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE
> (stmt_info)))
> + ? ? ? ? ? ? ?&& !PURE_SLP_STMT (stmt_info))
> +
> ? ? ? ? ? ? /* STMT needs both SLP and loop-based vectorization. ?*/
> ? ? ? ? ? ? only_slp_in_loop = false;
> ? ? ? ? }
> Index: tree-vect-slp.c
> ===================================================================
> --- tree-vect-slp.c ? ? (revision 156769)
> +++ tree-vect-slp.c ? ? (working copy)
> @@ -1102,6 +1102,7 @@ vect_detect_hybrid_slp_stmts (slp_tree n
> ? gimple stmt;
> ? imm_use_iterator imm_iter;
> ? gimple use_stmt;
> + ?stmt_vec_info stmt_vinfo;
>
> ? if (!node)
> ? ? return;
> @@ -1110,9 +1111,10 @@ vect_detect_hybrid_slp_stmts (slp_tree n
> ? ? if (PURE_SLP_STMT (vinfo_for_stmt (stmt))
> ? ? ? ?&& TREE_CODE (gimple_op (stmt, 0)) == SSA_NAME)
> ? ? ? FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, gimple_op (stmt, 0))
> - ? ? ? if (vinfo_for_stmt (use_stmt)
> - ? ? ? ? ? && !STMT_SLP_TYPE (vinfo_for_stmt (use_stmt))
> - ? ? ? ? ? ?&& STMT_VINFO_RELEVANT (vinfo_for_stmt (use_stmt)))
> + ? ? ? if ((stmt_vinfo = vinfo_for_stmt (use_stmt))
> + ? ? ? ? ? && !STMT_SLP_TYPE (stmt_vinfo)
> + ? ? ? ? ? ?&& (STMT_VINFO_RELEVANT (stmt_vinfo)
> + ? ? ? ? ? ? ? ?|| VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE
> (stmt_vinfo))))
> ? ? ? ? ?vect_mark_slp_stmts (node, hybrid, i);
>
> ? vect_detect_hybrid_slp_stmts (SLP_TREE_LEFT (node));
> Index: testsuite/gcc.dg/vect/fast-math-pr43074.c
> ===================================================================
> --- testsuite/gcc.dg/vect/fast-math-pr43074.c ? (revision 0)
> +++ testsuite/gcc.dg/vect/fast-math-pr43074.c ? (revision 0)
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +
> +float
> +pvslockprocess(float *fout, float *fin, int framesize)
> +{
> + ?int i;
> + ?float mag=0.0f, diff;
> + ?for (i = 0; i < framesize; i += 2) {
> + ? ? ?mag += fin[i];
> + ? ? ?fout[i] = fin[i];
> + ? ? ?fout[i+1] = fin[i+1];
> + ?}
> + ?return mag;
> +}
> +
> +/* { dg-final { cleanup-tree-dump "vect" } } */
>
>
> 4.4 patch:
>
> Index: tree-vect-analyze.c
> ===================================================================
> --- tree-vect-analyze.c (revision 156770)
> +++ tree-vect-analyze.c (working copy)
> @@ -3508,7 +3508,9 @@ vect_detect_hybrid_slp_stmts (slp_tree n
> ? ? ? FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, gimple_op (stmt, 0))
> ? ? ? ?if (vinfo_for_stmt (use_stmt)
> ? ? ? ? ? ?&& !STMT_SLP_TYPE (vinfo_for_stmt (use_stmt))
> - ? ? ? ? ? ?&& STMT_VINFO_RELEVANT (vinfo_for_stmt (use_stmt)))
> + ? ? ? ? ? ?&& (STMT_VINFO_RELEVANT (vinfo_for_stmt (use_stmt))
> + ? ? ? ? ? ? ? ?|| STMT_VINFO_DEF_TYPE (vinfo_for_stmt (use_stmt))
> + ? ? ? ? ? ? ? ? ? ?== vect_reduction_def))
> ? ? ? ? ?vect_mark_slp_stmts (node, hybrid, i);
>
> ? vect_detect_hybrid_slp_stmts (SLP_TREE_LEFT (node));
> Index: testsuite/gcc.dg/vect/fast-math-pr43074.c
> ===================================================================
> --- testsuite/gcc.dg/vect/fast-math-pr43074.c ? (revision 0)
> +++ testsuite/gcc.dg/vect/fast-math-pr43074.c ? (revision 0)
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +
> +float
> +pvslockprocess(float *fout, float *fin, int framesize)
> +{
> + ?int i;
> + ?float mag=0.0f, diff;
> + ?for (i = 0; i < framesize; i += 2) {
> + ? ? ?mag += fin[i];
> + ? ? ?fout[i] = fin[i];
> + ? ? ?fout[i+1] = fin[i+1];
> + ?}
> + ?return mag;
> +}
> +
> +/* { dg-final { cleanup-tree-dump "vect" } } */
>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]