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 VECT]Swap operands for cond_reduction when necessary


On Fri, Oct 28, 2016 at 1:38 PM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Wed, Oct 26, 2016 at 6:42 PM, Bin Cheng <Bin.Cheng@arm.com> wrote:
>> Hi,
>> For stmt defining reduction, GCC vectorizer assumes that the reduction variable is always the last (second) operand.  Another fact is that vectorizer doesn't swap operands for cond_reduction during analysis stage.  The problem is GCC middle-end may canonicalize cond_expr into a form that reduction variable is not the last one.  At the moment, such case cannot be vectorized.
>> The patch fixes this issue by swapping operands in cond_reduction when it's necessary.  The patch also swaps it back if vectorization fails.  The patch resolves failures introduced by previous match.pd patches.  In addition, couple cases are XPASSed on AArch64 now, which means more loops are vectorized.  I will send following patch addressing those XPASS tests.
>> Bootstrap and test on x86_64 and AArch64 ongoing, is it OK?
>
> @@ -1225,6 +1225,20 @@ destroy_loop_vec_info (loop_vec_info
> loop_vinfo, bool clean_stmts)
>                 swap_ssa_operands (stmt,
>                                    gimple_assign_rhs1_ptr (stmt),
>                                    gimple_assign_rhs2_ptr (stmt));
> +             else if (code == COND_EXPR
> +                      && CONSTANT_CLASS_P (gimple_assign_rhs2 (stmt)))
> +               {
> +                 tree cond_expr = gimple_assign_rhs1 (stmt);
> +                 enum tree_code cond_code = TREE_CODE (cond_expr);
> +
> +                 gcc_assert (TREE_CODE_CLASS (cond_code) == tcc_comparison);
> +                 /* HONOR_NANS doesn't matter when inverting it back.  */
>
> I think this doesn't hold true for COND_EXPRs that were originally
> this way as canonicalization
> is also inhibited by this.  I suggest to simply not invert back when
> cond_code == ERROR_MARK
> as we can't possibly have swapped it to the current non-canonical way.
>
> Ok with that change.
Thanks for reviewing, attachment is the updated patch as suggested.
Will apply it if no further problems.

Thanks,
bin

Attachment: vect-swap-cond_reduction-20161028.txt
Description: Text document


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