Re: Fix tree-nrv.c ICE for direct internal functions

2020-01-06 Thread Jeff Law
On Thu, 2019-12-12 at 15:13 +, Richard Sandiford wrote:
> pass_return_slot::execute has:
> 
> /* Ignore internal functions without direct optabs,
>those are expanded specially and aggregate_value_p
>on their result might result in undesirable warnings
>with some backends.  */
> && (!gimple_call_internal_p (stmt)
> || direct_internal_fn_p (gimple_call_internal_fn (stmt)))
> && aggregate_value_p (TREE_TYPE (gimple_call_lhs (stmt)),
>   gimple_call_fndecl (stmt)))
> 
> But what the comment says applies to directly-mapped internal functions
> too, since they're only used if the target supports them without a
> libcall.
> 
> This was triggering an ICE on the attached testcase.  The svld3 call
> is folded to an IFN_LOAD_LANES, which returns an array of vectors with
> VNx48QImode.  Since no such return type can exist in C, the target hook
> was complaining about an unexpected use of SVE modes.  (And we want to
> keep asserting for that, so that we don't accidentally define an ABI for
> an unexpected corner case.)
> 
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?
> 
> Richard
> 
> 
> 2019-12-12  Richard Sandiford  
> 
> gcc/
>   * tree-nrv.c (pass_return_slot::execute): Handle all internal
>   functions the same way, rather than singling out those that
>   aren't mapped directly to optabs.
> 
> gcc/testsuite/
>   * gcc.target/aarch64/sve/acle/general/nrv_1.c: New test.
OK
jeff




Ping: Fix tree-nrv.c ICE for direct internal functions

2019-12-19 Thread Richard Sandiford
Ping

Richard Sandiford  writes:
> pass_return_slot::execute has:
>
> /* Ignore internal functions without direct optabs,
>those are expanded specially and aggregate_value_p
>on their result might result in undesirable warnings
>with some backends.  */
> && (!gimple_call_internal_p (stmt)
> || direct_internal_fn_p (gimple_call_internal_fn (stmt)))
> && aggregate_value_p (TREE_TYPE (gimple_call_lhs (stmt)),
>   gimple_call_fndecl (stmt)))
>
> But what the comment says applies to directly-mapped internal functions
> too, since they're only used if the target supports them without a
> libcall.
>
> This was triggering an ICE on the attached testcase.  The svld3 call
> is folded to an IFN_LOAD_LANES, which returns an array of vectors with
> VNx48QImode.  Since no such return type can exist in C, the target hook
> was complaining about an unexpected use of SVE modes.  (And we want to
> keep asserting for that, so that we don't accidentally define an ABI for
> an unexpected corner case.)
>
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?
>
> Richard
>
>
> 2019-12-12  Richard Sandiford  
>
> gcc/
>   * tree-nrv.c (pass_return_slot::execute): Handle all internal
>   functions the same way, rather than singling out those that
>   aren't mapped directly to optabs.
>
> gcc/testsuite/
>   * gcc.target/aarch64/sve/acle/general/nrv_1.c: New test.
>
> Index: gcc/tree-nrv.c
> ===
> --- gcc/tree-nrv.c2019-03-08 18:15:26.824777889 +
> +++ gcc/tree-nrv.c2019-12-12 15:11:48.662767466 +
> @@ -378,12 +378,10 @@ pass_return_slot::execute (function *fun
> if (stmt
> && gimple_call_lhs (stmt)
> && !gimple_call_return_slot_opt_p (stmt)
> -   /* Ignore internal functions without direct optabs,
> -  those are expanded specially and aggregate_value_p
> -  on their result might result in undesirable warnings
> -  with some backends.  */
> -   && (!gimple_call_internal_p (stmt)
> -   || direct_internal_fn_p (gimple_call_internal_fn (stmt)))
> +   /* Ignore internal functions, those are expanded specially
> +  and aggregate_value_p on their result might result in
> +  undesirable warnings with some backends.  */
> +   && !gimple_call_internal_p (stmt)
> && aggregate_value_p (TREE_TYPE (gimple_call_lhs (stmt)),
>   gimple_call_fndecl (stmt)))
>   {
> Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general/nrv_1.c
> ===
> --- /dev/null 2019-09-17 11:41:18.176664108 +0100
> +++ gcc/testsuite/gcc.target/aarch64/sve/acle/general/nrv_1.c 2019-12-12 
> 15:11:48.662767466 +
> @@ -0,0 +1,17 @@
> +/* { dg-options "-O -msve-vector-bits=256" } */
> +
> +#include 
> +
> +typedef uint8_t v32qi __attribute__((vector_size (32)));
> +
> +struct triple { v32qi v0, v1, v2; };
> +
> +struct triple f (uint8_t *ptr)
> +{
> +  svuint8x3_t data = svld3 (svptrue_b8 (), ptr);
> +  struct triple res;
> +  res.v0 = svget3 (data, 0);
> +  res.v1 = svget3 (data, 1);
> +  res.v2 = svget3 (data, 2);
> +  return res;
> +}


Fix tree-nrv.c ICE for direct internal functions

2019-12-12 Thread Richard Sandiford
pass_return_slot::execute has:

  /* Ignore internal functions without direct optabs,
 those are expanded specially and aggregate_value_p
 on their result might result in undesirable warnings
 with some backends.  */
  && (!gimple_call_internal_p (stmt)
  || direct_internal_fn_p (gimple_call_internal_fn (stmt)))
  && aggregate_value_p (TREE_TYPE (gimple_call_lhs (stmt)),
gimple_call_fndecl (stmt)))

But what the comment says applies to directly-mapped internal functions
too, since they're only used if the target supports them without a
libcall.

This was triggering an ICE on the attached testcase.  The svld3 call
is folded to an IFN_LOAD_LANES, which returns an array of vectors with
VNx48QImode.  Since no such return type can exist in C, the target hook
was complaining about an unexpected use of SVE modes.  (And we want to
keep asserting for that, so that we don't accidentally define an ABI for
an unexpected corner case.)

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Richard


2019-12-12  Richard Sandiford  

gcc/
* tree-nrv.c (pass_return_slot::execute): Handle all internal
functions the same way, rather than singling out those that
aren't mapped directly to optabs.

gcc/testsuite/
* gcc.target/aarch64/sve/acle/general/nrv_1.c: New test.

Index: gcc/tree-nrv.c
===
--- gcc/tree-nrv.c  2019-03-08 18:15:26.824777889 +
+++ gcc/tree-nrv.c  2019-12-12 15:11:48.662767466 +
@@ -378,12 +378,10 @@ pass_return_slot::execute (function *fun
  if (stmt
  && gimple_call_lhs (stmt)
  && !gimple_call_return_slot_opt_p (stmt)
- /* Ignore internal functions without direct optabs,
-those are expanded specially and aggregate_value_p
-on their result might result in undesirable warnings
-with some backends.  */
- && (!gimple_call_internal_p (stmt)
- || direct_internal_fn_p (gimple_call_internal_fn (stmt)))
+ /* Ignore internal functions, those are expanded specially
+and aggregate_value_p on their result might result in
+undesirable warnings with some backends.  */
+ && !gimple_call_internal_p (stmt)
  && aggregate_value_p (TREE_TYPE (gimple_call_lhs (stmt)),
gimple_call_fndecl (stmt)))
{
Index: gcc/testsuite/gcc.target/aarch64/sve/acle/general/nrv_1.c
===
--- /dev/null   2019-09-17 11:41:18.176664108 +0100
+++ gcc/testsuite/gcc.target/aarch64/sve/acle/general/nrv_1.c   2019-12-12 
15:11:48.662767466 +
@@ -0,0 +1,17 @@
+/* { dg-options "-O -msve-vector-bits=256" } */
+
+#include 
+
+typedef uint8_t v32qi __attribute__((vector_size (32)));
+
+struct triple { v32qi v0, v1, v2; };
+
+struct triple f (uint8_t *ptr)
+{
+  svuint8x3_t data = svld3 (svptrue_b8 (), ptr);
+  struct triple res;
+  res.v0 = svget3 (data, 0);
+  res.v1 = svget3 (data, 1);
+  res.v2 = svget3 (data, 2);
+  return res;
+}