public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	       Richard Sandiford <richard.sandiford@arm.com>,
	       Segher Boessenkool <segher@kernel.crashing.org>,
	       "Joseph S. Myers" <joseph@codesourcery.com>,
	       Andreas Krebbel <krebbel@linux.ibm.com>,
	       Robin Dapp <rdapp@linux.ibm.com>
Subject: Re: [PATCH v3 1/9] Allow COND_EXPR and VEC_COND_EXPR condtions to trap
Date: Fri, 06 Sep 2019 15:45:00 -0000	[thread overview]
Message-ID: <6DCAE849-42F6-4538-8AE1-EE091F01FC3B@linux.ibm.com> (raw)
In-Reply-To: <CAFiYyc2k_andqHebmS8KATMZ3AWP=ch+3WzZK6do5DGvM3ifxg@mail.gmail.com>

> Am 06.09.2019 um 13:07 schrieb Richard Biener <richard.guenther@gmail.com>:
> 
> On Thu, Sep 5, 2019 at 1:10 PM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>> 
>> Right now gimplifier does not allow VEC_COND_EXPR's condition to trap
>> and introduces a temporary if this could happen, for example, generating
>> 
>>  _5 = _4 > { 2.0e+0, 2.0e+0, 2.0e+0, 2.0e+0 };
>>  _6 = VEC_COND_EXPR <_5, { -1, -1, -1, -1 }, { 0, 0, 0, 0 }>;
>> 
>> from GENERIC
>> 
>>  VEC_COND_EXPR < (*b > { 2.0e+0, 2.0e+0, 2.0e+0, 2.0e+0 }) ,
>>                  { -1, -1, -1, -1 } ,
>>                  { 0, 0, 0, 0 } >
>> 
>> This is not necessary and makes the resulting GIMPLE harder to analyze.
>> In particular, one of the next patches in series needs to get to
>> VEC_COND_EXPR's comparison code, which is not possible when a temporary
>> is introduced.
>> 
>> This patch takes special care to avoid introducing trapping comparisons
>> in GIMPLE_COND.  They are not allowed, because they would require 3
>> outgoing edges (then, else and EH), which is awkward to say the least.
>> Therefore, computations of such conditions should live in their own basic
>> blocks.
> 
> Comments inline (thanks for the work btw)
> 
>> #endif /* GCC_GIMPLE_EXPR_H */
>> diff --git a/gcc/gimple.c b/gcc/gimple.c
>> index 633ef512a19..fd14fbec15e 100644
>> --- a/gcc/gimple.c
>> +++ b/gcc/gimple.c
>> @@ -2144,6 +2144,8 @@ gimple_could_trap_p_1 (gimple *s, bool include_mem, bool include_stores)
>>       op = gimple_assign_rhs_code (s);
>>       if (get_gimple_rhs_class (op) == GIMPLE_BINARY_RHS)
>>        div = gimple_assign_rhs2 (s);
>> +      else if (op == COND_EXPR || op == VEC_COND_EXPR)
>> +       op = TREE_CODE (gimple_assign_rhs1 (s));
> 
> I think this is not correct since we can have
> 
> int i = fp > 1. ? intval1 : intval2
> 
> and thus FLOAT_TYPE_P (t)  is wrong.  You need to do
> 
>  t = TREE_TYPE (op);
> 
> as well I think.

Doesn't this mean there is a problem with the existing logic too? If `s`
is

    int i = fp > 1.;

then

    t = gimple_expr_type (s);

would give us BOOLEAN_TYPE instead of REAL_TYPE.


Also, the new logic will probably be a bit more complicated, since I
will first have to do:

    tree cond = gimple_assign_rhs1 (s);

then see if `cond` is not e.g. an SSA_NAME, but rather a tcc_comparison,
and only then

    t = TREE_TYPE (TREE_OPERAND (cond, 0))

So I'd rather send a new version before merging this :-)

  reply	other threads:[~2019-09-06 15:45 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05 11:10 [PATCH v3 0/9] S/390: Use signaling FP comparison instructions Ilya Leoshkevich
2019-09-05 11:10 ` [PATCH v3 1/9] Allow COND_EXPR and VEC_COND_EXPR condtions to trap Ilya Leoshkevich
2019-09-06 11:07   ` Richard Biener
2019-09-06 15:45     ` Ilya Leoshkevich [this message]
2019-09-09  8:43       ` Richard Biener
2019-09-05 11:11 ` [PATCH v3 5/9] S/390: Implement vcond expander for V1TI,V1TF Ilya Leoshkevich
2019-09-30 14:51   ` Andreas Krebbel
2019-09-05 11:11 ` [PATCH v3 6/9] S/390: Remove code duplication in vec_unordered<mode> Ilya Leoshkevich
2019-09-30 14:41   ` Andreas Krebbel
2019-09-05 11:11 ` [PATCH v3 4/9] S/390: Do not use signaling vector comparisons on z13 Ilya Leoshkevich
2019-09-06 10:34   ` Segher Boessenkool
2019-09-30 13:36     ` Ilya Leoshkevich
2019-10-01  0:24       ` Segher Boessenkool
2019-09-05 11:11 ` [PATCH v3 3/9] Introduce can_vector_compare_p function Ilya Leoshkevich
2019-09-06 12:58   ` Richard Sandiford
2019-09-05 11:11 ` [PATCH v3 2/9] Introduce rtx_alloca, alloca_raw_REG and alloca_rtx_fmt_* Ilya Leoshkevich
2019-09-06 11:09   ` Richard Biener
2019-09-06 12:40   ` Richard Sandiford
2019-09-30 15:00     ` Ilya Leoshkevich
2019-09-05 11:12 ` [PATCH v3 8/9] S/390: Use signaling FP comparison instructions Ilya Leoshkevich
2019-09-05 11:12 ` [PATCH v3 7/9] S/390: Remove code duplication in vec_* comparison expanders Ilya Leoshkevich
2019-09-30 14:50   ` Andreas Krebbel
2019-09-05 11:12 ` [PATCH v3 9/9] S/390: Test signaling FP comparison instructions Ilya Leoshkevich

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=6DCAE849-42F6-4538-8AE1-EE091F01FC3B@linux.ibm.com \
    --to=iii@linux.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=krebbel@linux.ibm.com \
    --cc=rdapp@linux.ibm.com \
    --cc=richard.guenther@gmail.com \
    --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).