From: Richard Sandiford <richard.sandiford@arm.com>
To: Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
Cc: gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [SVE] PR91272
Date: Tue, 22 Oct 2019 07:51:00 -0000 [thread overview]
Message-ID: <mptlftdi5tv.fsf@arm.com> (raw)
In-Reply-To: <CAAgBjMmm2vhzocznP+oxfQEXm4j8stEsbJtG6Kt7Go84ATnxsA@mail.gmail.com> (Prathamesh Kulkarni's message of "Tue, 22 Oct 2019 01:41:40 +0530")
Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> writes:
> diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
> index acdd90784dc..dfd33b142ed 100644
> --- a/gcc/tree-vect-stmts.c
> +++ b/gcc/tree-vect-stmts.c
> @@ -10016,25 +10016,26 @@ vectorizable_condition (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
> /* See whether another part of the vectorized code applies a loop
> mask to the condition, or to its inverse. */
>
> + vec_loop_masks *masks = NULL;
> if (loop_vinfo && LOOP_VINFO_FULLY_MASKED_P (loop_vinfo))
> {
> - scalar_cond_masked_key cond (cond_expr, ncopies);
> - if (loop_vinfo->scalar_cond_masked_set.contains (cond))
> - {
> - vec_loop_masks *masks = &LOOP_VINFO_MASKS (loop_vinfo);
> - loop_mask = vect_get_loop_mask (gsi, masks, ncopies, vectype, j);
> - }
> + if (reduction_type == EXTRACT_LAST_REDUCTION)
> + masks = &LOOP_VINFO_MASKS (loop_vinfo);
> else
> {
> - bool honor_nans = HONOR_NANS (TREE_TYPE (cond.op0));
> - cond.code = invert_tree_comparison (cond.code, honor_nans);
> + scalar_cond_masked_key cond (cond_expr, ncopies);
> if (loop_vinfo->scalar_cond_masked_set.contains (cond))
> + masks = &LOOP_VINFO_MASKS (loop_vinfo);
> + else
> {
> - vec_loop_masks *masks = &LOOP_VINFO_MASKS (loop_vinfo);
> - loop_mask = vect_get_loop_mask (gsi, masks, ncopies,
> - vectype, j);
> - cond_code = cond.code;
> - swap_cond_operands = true;
> + bool honor_nans = HONOR_NANS (TREE_TYPE (cond.op0));
> + cond.code = invert_tree_comparison (cond.code, honor_nans);
> + if (loop_vinfo->scalar_cond_masked_set.contains (cond))
> + {
> + masks = &LOOP_VINFO_MASKS (loop_vinfo);
> + cond_code = cond.code;
> + swap_cond_operands = true;
> + }
> }
> }
> }
> @@ -10116,6 +10117,13 @@ vectorizable_condition (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
> vec_then_clause = vec_oprnds2[i];
> vec_else_clause = vec_oprnds3[i];
>
> + if (masks)
> + {
> + unsigned vec_num = vec_oprnds0.length ();
> + loop_mask = vect_get_loop_mask (gsi, masks, vec_num * ncopies,
> + vectype, vec_num * j + i);
> + }
> +
I don't think we need an extra "if" here. "loop_mask" only feeds
the later "if (loop_mask)" block, so we might as well change that
later "if" to "if (masks)" and make the "loop_mask" variable local
to the "if" body.
> if (swap_cond_operands)
> std::swap (vec_then_clause, vec_else_clause);
>
> @@ -10194,23 +10202,6 @@ vectorizable_condition (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
> vec_compare = tmp;
> }
>
> - tree tmp2 = make_ssa_name (vec_cmp_type);
> - gassign *g = gimple_build_assign (tmp2, BIT_AND_EXPR,
> - vec_compare, loop_mask);
> - vect_finish_stmt_generation (stmt_info, g, gsi);
> - vec_compare = tmp2;
> - }
> -
> - if (reduction_type == EXTRACT_LAST_REDUCTION)
> - {
> - if (!is_gimple_val (vec_compare))
> - {
> - tree vec_compare_name = make_ssa_name (vec_cmp_type);
> - gassign *new_stmt = gimple_build_assign (vec_compare_name,
> - vec_compare);
> - vect_finish_stmt_generation (stmt_info, new_stmt, gsi);
> - vec_compare = vec_compare_name;
> - }
This form is simpler than:
if (COMPARISON_CLASS_P (vec_compare))
{
tree tmp = make_ssa_name (vec_cmp_type);
tree op0 = TREE_OPERAND (vec_compare, 0);
tree op1 = TREE_OPERAND (vec_compare, 1);
gassign *g = gimple_build_assign (tmp,
TREE_CODE (vec_compare),
op0, op1);
vect_finish_stmt_generation (stmt_info, g, gsi);
vec_compare = tmp;
}
so I think it'd be better to keep the EXTRACT_LAST_REDUCTION version.
Thanks,
Richard
next prev parent reply other threads:[~2019-10-22 7:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 1:48 Prathamesh Kulkarni
2019-10-18 9:07 ` Richard Sandiford
2019-10-21 20:16 ` Prathamesh Kulkarni
2019-10-22 7:51 ` Richard Sandiford [this message]
2019-10-24 5:44 ` Prathamesh Kulkarni
2019-10-25 9:12 ` Richard Sandiford
2019-10-25 19:58 ` Prathamesh Kulkarni
2019-10-27 13:41 ` Richard Sandiford
2019-10-28 15:02 ` Prathamesh Kulkarni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=mptlftdi5tv.fsf@arm.com \
--to=richard.sandiford@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=prathamesh.kulkarni@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).