public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] veclower: Don't ICE on .VEC_CONVERT calls with no lhs [PR96426]
@ 2020-08-04  8:43 Jakub Jelinek
  2020-08-04  8:53 ` Richard Sandiford
  2020-08-04  9:11 ` Richard Biener
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2020-08-04  8:43 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

Hi!

.VEC_CONVERT is a const internal call, so normally if the lhs is not used,
we'd DCE it far before getting to veclower, but with -O0 (or perhaps
-fno-tree-dce and some other -fno-* options) it can happen.
But as the internal fn needs the lhs to know the type to which the
conversion is done (and I think that is a reasonable representation, having
some magic another argument and having to create constants with that type
looks overkill to me), we just should DCE those calls ourselves.
During veclower, we can't really remove insns, as the callers would be
upset, so this just replaces it with a GIMPLE_NOP.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2020-08-04  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/96426
	* tree-vect-generic.c (expand_vector_conversion): Replace .VEC_CONVERT
	call with GIMPLE_NOP if there is no lhs.

	* gcc.c-torture/compile/pr96426.c: New test.

--- gcc/tree-vect-generic.c.jj	2020-07-28 15:39:10.081755224 +0200
+++ gcc/tree-vect-generic.c	2020-08-03 12:34:32.193423693 +0200
@@ -1775,6 +1775,12 @@ expand_vector_conversion (gimple_stmt_it
   gimple *stmt = gsi_stmt (*gsi);
   gimple *g;
   tree lhs = gimple_call_lhs (stmt);
+  if (lhs == NULL_TREE)
+    {
+      g = gimple_build_nop ();
+      gsi_replace (gsi, g, false);
+      return;
+    }
   tree arg = gimple_call_arg (stmt, 0);
   tree ret_type = TREE_TYPE (lhs);
   tree arg_type = TREE_TYPE (arg);
--- gcc/testsuite/gcc.c-torture/compile/pr96426.c.jj	2020-08-03 12:40:23.442449729 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr96426.c	2020-08-03 12:40:09.458647750 +0200
@@ -0,0 +1,10 @@
+/* PR middle-end/96426 */
+
+typedef long long V __attribute__((vector_size(16)));
+typedef double W __attribute__((vector_size(16)));
+
+void
+foo (V *v)
+{
+  __builtin_convertvector (*v, W);
+}

	Jakub


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] veclower: Don't ICE on .VEC_CONVERT calls with no lhs [PR96426]
  2020-08-04  8:43 [PATCH] veclower: Don't ICE on .VEC_CONVERT calls with no lhs [PR96426] Jakub Jelinek
@ 2020-08-04  8:53 ` Richard Sandiford
  2020-08-04  9:11 ` Richard Biener
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Sandiford @ 2020-08-04  8:53 UTC (permalink / raw)
  To: Jakub Jelinek via Gcc-patches; +Cc: Richard Biener, Jakub Jelinek

Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
> Hi!
>
> .VEC_CONVERT is a const internal call, so normally if the lhs is not used,
> we'd DCE it far before getting to veclower, but with -O0 (or perhaps
> -fno-tree-dce and some other -fno-* options) it can happen.
> But as the internal fn needs the lhs to know the type to which the
> conversion is done (and I think that is a reasonable representation, having
> some magic another argument and having to create constants with that type
> looks overkill to me), we just should DCE those calls ourselves.

FWIW, the reason we took that approach for .WHILE_ULT was for things
like value numbering.  It seems reasonable to expect that one const call
to internal function F with arguments A produces the same result as
another const call to internal function F with arguments A, without
having to differentiate based on lhs type as well.

(Not a comment on the patch itself btw.)

Thanks,
Richard

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] veclower: Don't ICE on .VEC_CONVERT calls with no lhs [PR96426]
  2020-08-04  8:43 [PATCH] veclower: Don't ICE on .VEC_CONVERT calls with no lhs [PR96426] Jakub Jelinek
  2020-08-04  8:53 ` Richard Sandiford
@ 2020-08-04  9:11 ` Richard Biener
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Biener @ 2020-08-04  9:11 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Tue, 4 Aug 2020, Jakub Jelinek wrote:

> Hi!
> 
> .VEC_CONVERT is a const internal call, so normally if the lhs is not used,
> we'd DCE it far before getting to veclower, but with -O0 (or perhaps
> -fno-tree-dce and some other -fno-* options) it can happen.
> But as the internal fn needs the lhs to know the type to which the
> conversion is done (and I think that is a reasonable representation, having
> some magic another argument and having to create constants with that type
> looks overkill to me), we just should DCE those calls ourselves.
> During veclower, we can't really remove insns, as the callers would be
> upset, so this just replaces it with a GIMPLE_NOP.
> 
> Bootstrapped/regtested on x86_64-linux, ok for trunk?

OK.

Richard.

> 2020-08-04  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR middle-end/96426
> 	* tree-vect-generic.c (expand_vector_conversion): Replace .VEC_CONVERT
> 	call with GIMPLE_NOP if there is no lhs.
> 
> 	* gcc.c-torture/compile/pr96426.c: New test.
> 
> --- gcc/tree-vect-generic.c.jj	2020-07-28 15:39:10.081755224 +0200
> +++ gcc/tree-vect-generic.c	2020-08-03 12:34:32.193423693 +0200
> @@ -1775,6 +1775,12 @@ expand_vector_conversion (gimple_stmt_it
>    gimple *stmt = gsi_stmt (*gsi);
>    gimple *g;
>    tree lhs = gimple_call_lhs (stmt);
> +  if (lhs == NULL_TREE)
> +    {
> +      g = gimple_build_nop ();
> +      gsi_replace (gsi, g, false);
> +      return;
> +    }
>    tree arg = gimple_call_arg (stmt, 0);
>    tree ret_type = TREE_TYPE (lhs);
>    tree arg_type = TREE_TYPE (arg);
> --- gcc/testsuite/gcc.c-torture/compile/pr96426.c.jj	2020-08-03 12:40:23.442449729 +0200
> +++ gcc/testsuite/gcc.c-torture/compile/pr96426.c	2020-08-03 12:40:09.458647750 +0200
> @@ -0,0 +1,10 @@
> +/* PR middle-end/96426 */
> +
> +typedef long long V __attribute__((vector_size(16)));
> +typedef double W __attribute__((vector_size(16)));
> +
> +void
> +foo (V *v)
> +{
> +  __builtin_convertvector (*v, W);
> +}
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-04  9:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04  8:43 [PATCH] veclower: Don't ICE on .VEC_CONVERT calls with no lhs [PR96426] Jakub Jelinek
2020-08-04  8:53 ` Richard Sandiford
2020-08-04  9:11 ` Richard Biener

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).