From: Richard Biener <richard.guenther@gmail.com>
To: "Martin Liška" <mliska@suse.cz>,
"Richard Biener" <richard.guenther@gmail.com>,
"Segher Boessenkool" <segher@kernel.crashing.org>,
"GCC Patches" <gcc-patches@gcc.gnu.org>,
"Richard Sandiford" <richard.sandiford@arm.com>
Subject: Re: [stage1][PATCH] Lower VEC_COND_EXPR into internal functions.
Date: Fri, 29 May 2020 14:43:12 +0200 [thread overview]
Message-ID: <CAFiYyc0TPD1mR075dWvxTD+zF9JbV-T=48cXmmSR1VPNagdxMA@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc1X5VH=aWyYwaF8HMxUXOfA_b2jzc=8kH+GkQ-xkgASjw@mail.gmail.com>
On Fri, May 29, 2020 at 2:17 PM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Thu, May 28, 2020 at 5:28 PM Richard Sandiford
> <richard.sandiford@arm.com> wrote:
> >
> > Martin Liška <mliska@suse.cz> writes:
> > > Hi.
> > >
> > > There's a new patch that adds normal internal functions for the 4
> > > VCOND* functions.
> > >
> > > The patch that survives bootstrap and regression
> > > tests on x86_64-linux-gnu and ppc64le-linux-gnu.
> >
> > I think this has the same problem as the previous one. What I meant
> > in yesterday's message is that:
> >
> > expand_insn (icode, 6, ops);
> >
> > is simply not valid when icode is allowed to FAIL. That's true in
> > any context, not just internal functions. If icode does FAIL,
> > the expand_insn call will ICE:
> >
> > if (!maybe_expand_insn (icode, nops, ops))
> > gcc_unreachable ();
> >
> > When using optabs you either:
> >
> > (a) declare that the md patterns aren't allowed to FAIL. expand_insn
> > is for this case.
> >
> > (b) allow the md patterns to FAIL and provide a fallback when they do.
> > maybe_expand_insn is for this case.
> >
> > So if we keep IFN_VCOND, we need to use maybe_expand_insn and find some
> > way of implementing the IFN_VCOND when the pattern FAILs.
>
> But we should not have generated the pattern in that case - we actually verify
> we can expand at the time we do this "instruction selection". This is in-line
> with other vectorizations where we also do not expect things to FAIL.
>
> See also the expanders that are removed in the patch.
>
> But adding a comment in the internal function expander to reflect this
> is probably good, also pointing to the verification routines (the
> preexisting expand_vec_cond_expr_p and expand_vec_cmp_expr_p
> routines). Because of this pre-verification I suggested the direct
> internal function first, not being aware of the static cannot-FAIL logic.
>
> Now it looks like that those verification also simply checks optab
> availability only but then this is just a preexisting issue (and we can
> possibly build a testcase that FAILs RTL expansion for power...).
>
> So given that this means the latent bug in the powerpc backend
> should be fixed and we should use a direct internal function instead?
So I tried to understand the circumstances the rs6000 patterns FAIL
but FAILed ;) It looks like some outs of rs6000_emit_vector_cond_expr
are unwarranted and the following should work:
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 8435bc15d72..5503215a00a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -14638,8 +14638,7 @@ rs6000_emit_vector_compare (enum rtx_code rcode,
rtx mask2;
rev_code = reverse_condition_maybe_unordered (rcode);
- if (rev_code == UNKNOWN)
- return NULL_RTX;
+ gcc_assert (rev_code != UNKNOWN);
nor_code = optab_handler (one_cmpl_optab, dmode);
if (nor_code == CODE_FOR_nothing)
@@ -14737,8 +14736,7 @@ rs6000_emit_vector_cond_expr (rtx dest, rtx
op_true, rtx op_false,
rtx cond2;
bool invert_move = false;
- if (VECTOR_UNIT_NONE_P (dest_mode))
- return 0;
+ gcc_assert (VECTOR_UNIT_NONE_P (dest_mode));
gcc_assert (GET_MODE_SIZE (dest_mode) == GET_MODE_SIZE (mask_mode)
&& GET_MODE_NUNITS (dest_mode) == GET_MODE_NUNITS (mask_mode));
@@ -14756,8 +14754,7 @@ rs6000_emit_vector_cond_expr (rtx dest, rtx
op_true, rtx op_false,
e.g., A = (B != C) ? D : E becomes A = (B == C) ? E : D. */
invert_move = true;
rcode = reverse_condition_maybe_unordered (rcode);
- if (rcode == UNKNOWN)
- return 0;
+ gcc_assert (rcode != UNKNOWN);
break;
case GE:
which leaves the
/* Get the vector mask for the given relational operations. */
mask = rs6000_emit_vector_compare (rcode, cc_op0, cc_op1, mask_mode);
if (!mask)
return 0;
fail but that function recurses heavily - from reading
rs6000_emit_vector_compare_inner
it looks like power can do a lot of compares but floating-point LT which
reverse_condition_maybe_unordered would turn into UNGE which is not
handled either.
But then rs6000_emit_vector_compare just tries GT for that anyway (not UNGE) so
it is actually be handled (but should not?).
So I bet the expansion of the patterns cannot fail at the moment. Thus I'd
replace the FAIL with a gcc_unreachable () and see if we have test
coverage for those
FAILs.
Segher - do you actually know this code to guess why the patterns are defensive?
Thanks,
Richard.
> Thanks,
> Richard.
>
> > Thanks,
> > Richard
next prev parent reply other threads:[~2020-05-29 12:43 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-24 10:25 [PATCH][RFC] Come up with VEC_COND_OP_EXPRs Martin Liška
2019-09-24 11:11 ` Richard Sandiford
2019-09-24 11:29 ` Richard Biener
2019-09-24 11:57 ` Richard Sandiford
2019-09-24 12:18 ` Richard Biener
2019-09-24 14:51 ` Richard Sandiford
2020-04-01 10:19 ` [stage1][PATCH] Lower VEC_COND_EXPR into internal functions Martin Liška
2020-04-06 9:17 ` Richard Sandiford
2020-04-06 12:30 ` Richard Biener
2020-05-21 12:51 ` Martin Liška
2020-05-21 13:29 ` Martin Liška
2020-05-21 20:16 ` Segher Boessenkool
2020-05-22 11:14 ` Richard Biener
2020-05-26 10:15 ` Richard Sandiford
2020-05-27 14:04 ` Martin Liška
2020-05-27 16:13 ` Richard Sandiford
2020-05-27 16:32 ` Richard Biener
2020-05-28 14:46 ` Martin Liška
2020-05-28 15:28 ` Richard Sandiford
2020-05-29 12:17 ` Richard Biener
2020-05-29 12:43 ` Richard Biener [this message]
2020-05-29 16:47 ` Segher Boessenkool
2020-05-29 17:05 ` Richard Sandiford
2020-05-29 17:30 ` Segher Boessenkool
2020-05-29 15:39 ` Segher Boessenkool
2020-05-29 16:57 ` Richard Sandiford
2020-05-29 17:09 ` Segher Boessenkool
2020-05-29 17:26 ` Richard Sandiford
2020-05-29 17:37 ` Segher Boessenkool
2020-05-30 7:15 ` Richard Sandiford
2020-05-30 13:08 ` Segher Boessenkool
2020-06-02 11:09 ` Richard Biener
2020-06-02 15:00 ` Martin Liška
2020-06-03 7:38 ` Richard Biener
2020-06-03 13:41 ` Richard Sandiford
2020-06-03 14:17 ` David Edelsohn
2020-06-03 14:46 ` Richard Biener
2020-06-03 17:01 ` Segher Boessenkool
2020-06-03 17:23 ` Richard Biener
2020-06-03 18:23 ` Segher Boessenkool
2020-06-03 18:38 ` Richard Biener
2020-06-03 18:46 ` David Edelsohn
2020-06-03 19:09 ` Segher Boessenkool
2020-06-03 19:13 ` Jakub Jelinek
2020-06-03 18:27 ` Segher Boessenkool
2020-06-08 11:04 ` Martin Liška
2020-06-09 13:42 ` Richard Biener
2020-06-10 8:51 ` Martin Liška
2020-06-10 10:50 ` Richard Biener
2020-06-10 12:27 ` Martin Liška
2020-06-10 13:01 ` Martin Liška
2020-06-11 8:52 ` Martin Liška
2020-06-12 9:43 ` Richard Biener
2020-06-12 13:24 ` Martin Liška
2020-06-15 7:14 ` Richard Biener
2020-06-15 11:19 ` Martin Liška
2020-06-15 11:59 ` Richard Biener
2020-06-15 12:20 ` Martin Liška
2020-06-17 8:50 ` Richard Biener
2020-06-17 13:15 ` Richard Biener
2020-06-18 8:10 ` Martin Liška
2020-06-18 8:52 ` Richard Biener
2020-06-18 9:02 ` Martin Liška
2020-06-18 9:29 ` Martin Liška
2020-04-06 12:33 ` Richard Biener
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='CAFiYyc0TPD1mR075dWvxTD+zF9JbV-T=48cXmmSR1VPNagdxMA@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=mliska@suse.cz \
--cc=richard.sandiford@arm.com \
--cc=segher@kernel.crashing.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).