public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] (gimple) Allow integer return type from vector compares
@ 2017-10-12 20:03 Will Schmidt
  2017-10-13  9:26 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Will Schmidt @ 2017-10-12 20:03 UTC (permalink / raw)
  To: GCC Patches
  Cc: Richard Biener, Segher Boessenkool, Bill Schmidt, David Edelsohn

Hi, 
    
Update the logic in verify_gimple_comparision to allow a vector integer result
from a vector comparison, where it previously was limited to only allowing
compares with boolean results.  This allows powerpc intrinsics such as this
one to build (after gimple folding):
   vector bool int vec_cmpeq (vector signed int, vector signed int);

This has been tested in conjunction with the "rs6000 GIMPLE folding for vector
compares" patch (posted separately) on p6 and newer.

OK for trunk?
    
Thanks,
-Will
    
[gcc]

2017-10-12  Will Schmidt  <will_schmidt@vnet.ibm.com>

	* gcc/tree-cfg.c: (@ verify_gimple_comparison ): allow boolean result
	from vector compares.

diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index b5e0460..adf3607 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -3624,14 +3624,16 @@ verify_gimple_comparison (tree type, tree op0, tree op1, enum tree_code code)
 	  debug_generic_expr (op0_type);
 	  debug_generic_expr (op1_type);
 	  return true;
         }
     }
-  /* Or a boolean vector type with the same element count
-     as the comparison operand types.  */
+  /* Or a vector type with the same element count
+     as the comparison operand types.  The vector type may
+     be boolean or integer.  */
   else if (TREE_CODE (type) == VECTOR_TYPE
-	   && TREE_CODE (TREE_TYPE (type)) == BOOLEAN_TYPE)
+	   && (( TREE_CODE (TREE_TYPE (type)) == BOOLEAN_TYPE)
+	   || ( TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)))
     {
       if (TREE_CODE (op0_type) != VECTOR_TYPE
 	  || TREE_CODE (op1_type) != VECTOR_TYPE)
         {
           error ("non-vector operands in vector comparison");


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

* Re: [PATCH] (gimple) Allow integer return type from vector compares
  2017-10-12 20:03 [PATCH] (gimple) Allow integer return type from vector compares Will Schmidt
@ 2017-10-13  9:26 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-10-13  9:26 UTC (permalink / raw)
  To: will_schmidt
  Cc: GCC Patches, Segher Boessenkool, Bill Schmidt, David Edelsohn

On Thu, Oct 12, 2017 at 10:02 PM, Will Schmidt
<will_schmidt@vnet.ibm.com> wrote:
> Hi,
>
> Update the logic in verify_gimple_comparision to allow a vector integer result
> from a vector comparison, where it previously was limited to only allowing
> compares with boolean results.  This allows powerpc intrinsics such as this
> one to build (after gimple folding):
>    vector bool int vec_cmpeq (vector signed int, vector signed int);
>
> This has been tested in conjunction with the "rs6000 GIMPLE folding for vector
> compares" patch (posted separately) on p6 and newer.
>
> OK for trunk?

Well.  It was this way before AVX512 introduced those vector boolean
types.  There
we decided to have comparisons always return a boolean vector.  Previously
there was an additional restriction in that the vector elements of the
boolean result
had to be the same size as the elements of the comparison operands.

You are now supposed to use the "canonical"

 _1 = _2 != _3 ? { your true value vector } : { your false value vector};

with a VEC_COND_EXPR.

Richard.

> Thanks,
> -Will
>
> [gcc]
>
> 2017-10-12  Will Schmidt  <will_schmidt@vnet.ibm.com>
>
>         * gcc/tree-cfg.c: (@ verify_gimple_comparison ): allow boolean result
>         from vector compares.
>
> diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
> index b5e0460..adf3607 100644
> --- a/gcc/tree-cfg.c
> +++ b/gcc/tree-cfg.c
> @@ -3624,14 +3624,16 @@ verify_gimple_comparison (tree type, tree op0, tree op1, enum tree_code code)
>           debug_generic_expr (op0_type);
>           debug_generic_expr (op1_type);
>           return true;
>          }
>      }
> -  /* Or a boolean vector type with the same element count
> -     as the comparison operand types.  */
> +  /* Or a vector type with the same element count
> +     as the comparison operand types.  The vector type may
> +     be boolean or integer.  */
>    else if (TREE_CODE (type) == VECTOR_TYPE
> -          && TREE_CODE (TREE_TYPE (type)) == BOOLEAN_TYPE)
> +          && (( TREE_CODE (TREE_TYPE (type)) == BOOLEAN_TYPE)
> +          || ( TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)))
>      {
>        if (TREE_CODE (op0_type) != VECTOR_TYPE
>           || TREE_CODE (op1_type) != VECTOR_TYPE)
>          {
>            error ("non-vector operands in vector comparison");
>
>

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

end of thread, other threads:[~2017-10-13  9:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-12 20:03 [PATCH] (gimple) Allow integer return type from vector compares Will Schmidt
2017-10-13  9:26 ` 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).