public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Ilya Enkovich <enkovich.gnu@gmail.com>, gcc-patches@gcc.gnu.org
Subject: Re: [Boolean Vector, patch 3/5] Use boolean vector in C/C++ FE
Date: Fri, 09 Oct 2015 20:51:00 -0000	[thread overview]
Message-ID: <561828E4.6070905@redhat.com> (raw)
In-Reply-To: <20151002140449.GG26618@msticlxl57.ims.intel.com>

On 10/02/2015 08:04 AM, Ilya Enkovich wrote:
> Hi,
>
> This patch makes C/C++ FE to use boolean vector as a resulting type for vector comparison.  As a result vector comparison in source code now parsed into VEC_COND_EXPR, it required a testcase fix-up.
>
> Thanks,
> Ilya
> --
> gcc/c
>
> 2015-10-02  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
> 	* c-typeck.c (build_conditional_expr): Use boolean vector
> 	type for vector comparison.
> 	(build_vec_cmp): New.
> 	(build_binary_op): Use build_vec_cmp for comparison.
>
> gcc/cp
>
> 2015-10-02  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
> 	* call.c (build_conditional_expr_1): Use boolean vector
> 	type for vector comparison.
> 	* typeck.c (build_vec_cmp): New.
> 	(cp_build_binary_op): Use build_vec_cmp for comparison.
>
> gcc/testsuite/
>
> 2015-10-02  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
> 	* g++.dg/ext/vector22.C: Allow VEC_COND_EXPR.
>
>
> diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
> index 3b26231..3f64d76 100644
> --- a/gcc/c/c-typeck.c
> +++ b/gcc/c/c-typeck.c
> @@ -10220,6 +10232,19 @@ push_cleanup (tree decl, tree cleanup, bool eh_only)
>     STATEMENT_LIST_STMT_EXPR (list) = stmt_expr;
>   }
>   \f
> +/* Build a vector comparison using VEC_COND_EXPR.  */
Please make sure your function comments include descriptions of all the 
arguments and return values.


> +
> +static tree
> +build_vec_cmp (tree_code code, tree type,
> +	       tree arg0, tree arg1)
> +{
> +  tree zero_vec = build_zero_cst (type);
> +  tree minus_one_vec = build_minus_one_cst (type);
> +  tree cmp_type = build_same_sized_truth_vector_type (type);
> +  tree cmp = build2 (code, cmp_type, arg0, arg1);
> +  return build3 (VEC_COND_EXPR, type, cmp, minus_one_vec, zero_vec);
> +}
Isn't this implementation the same for C & C++?  Does it make sense to 
put it in c-family/c-common.c?


> +
>   /* Build a binary-operation expression without default conversions.
>      CODE is the kind of expression to build.
>      LOCATION is the operator's location.
> @@ -10786,7 +10811,8 @@ build_binary_op (location_t location, enum tree_code code,
>             result_type = build_opaque_vector_type (intt,
>   						  TYPE_VECTOR_SUBPARTS (type0));
>             converted = 1;
> -          break;
> +	  ret = build_vec_cmp (resultcode, result_type, op0, op1);
> +          goto return_build_binary_op;
I suspect there's some kind of whitespace/tab problem.  Those two lines 
should be indented the same, right?


>           }
>         if (FLOAT_TYPE_P (type0) || FLOAT_TYPE_P (type1))
>   	warning_at (location,
> @@ -10938,7 +10964,8 @@ build_binary_op (location_t location, enum tree_code code,
>             result_type = build_opaque_vector_type (intt,
>   						  TYPE_VECTOR_SUBPARTS (type0));
>             converted = 1;
> -          break;
> +	  ret = build_vec_cmp (resultcode, result_type, op0, op1);
> +          goto return_build_binary_op;
Similarly here.

With the items above fixed, this is OK.

However, more generally, do we need to do anything for the other languages?

Jeff

  reply	other threads:[~2015-10-09 20:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-02 14:05 Ilya Enkovich
2015-10-09 20:51 ` Jeff Law [this message]
2015-10-13 14:15   ` Ilya Enkovich
2015-10-13 15:42     ` Jeff Law
2015-10-13 15:59       ` Ilya Enkovich
2015-10-20 21:36         ` Jeff Law
2015-10-21 11:24           ` Ilya Enkovich

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=561828E4.6070905@redhat.com \
    --to=law@redhat.com \
    --cc=enkovich.gnu@gmail.com \
    --cc=gcc-patches@gcc.gnu.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).