public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Alan Hayward <alan.hayward@arm.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [Patch] Avoid is_simple_use bug in vectorizable_live_operation
Date: Tue, 27 Oct 2015 11:37:00 -0000	[thread overview]
Message-ID: <CAFiYyc2-3s0eGjVy5hgexTNvjL3qp1RcgXJv8kBNV0JKqFRWyA@mail.gmail.com> (raw)
In-Reply-To: <D2540F86.9261%alan.hayward@arm.com>

On Mon, Oct 26, 2015 at 6:15 PM, Alan Hayward <alan.hayward@arm.com> wrote:
>
>
> On 26/10/2015 13:35, "Richard Biener" <richard.guenther@gmail.com> wrote:
>
>>On Mon, Oct 26, 2015 at 1:33 PM, Alan Hayward <alan.hayward@arm.com>
>>wrote:
>>> There is a potential bug in vectorizable_live_operation.
>>>
>>> Consider the case where the first op for stmt is valid, but the second
>>>is
>>> null.
>>> The first time through the for () loop, it will call out to
>>> vect_is_simple_use () which will set dt.
>>> The second time, because op is null, vect_is_simple_use () will not be
>>> called.
>>> However, dt is still set to a valid value, therefore the loop will
>>> continue.
>>>
>>> Note this is different from the case where the first op is null, which
>>> will cause the loop not call vect_is_simple_use () and then return
>>>false.
>>>
>>> It is possible that this was intentional, however that is not clear from
>>> the code.
>>>
>>> The fix is to simply ensure dt is initialized to a default value on each
>>> iteration.
>>
>>I think the patch is a strict improvement, thus OK.  Still a NULL operand
>>is not possible in GIMPLE so the op && check is not necessary.  The way
>>it iterates over all stmt uses is a bit scary anyway.  As it is ok with
>>all invariants it should probably simply do sth like
>>
>>   FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE)
>>     if (!vect_is_simple_use (op, ....))
>>
>>and be done with that.  Unvisited uses can only be constants (ok).
>>
>>Care to rework the funtion like that if you are here?
>>
>
> Ok, I’ve updated as requested.

Ok.  Please remove

  code = gimple_assign_rhs_code (stmt);
  op_type = TREE_CODE_LENGTH (code);
  rhs_class = get_gimple_rhs_class (code);
  gcc_assert (rhs_class != GIMPLE_UNARY_RHS || op_type == unary_op);
  gcc_assert (rhs_class != GIMPLE_BINARY_RHS || op_type == binary_op);

and associated variables as I belive otherwise a --disable-checking build
will fail with set-but-not-used warnings.  And the asserts are quite pointless
given the now sanitized loop.

Thanks,
Richard.

>
> Cheers,
> Alan.
>

  reply	other threads:[~2015-10-27 11:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-26 12:54 Alan Hayward
2015-10-26 13:42 ` Richard Biener
2015-10-26 17:15   ` Alan Hayward
2015-10-27 11:37     ` Richard Biener [this message]
2015-10-27 13:45       ` Alan Hayward
2015-10-27 13:52         ` Richard Biener

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=CAFiYyc2-3s0eGjVy5hgexTNvjL3qp1RcgXJv8kBNV0JKqFRWyA@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=alan.hayward@arm.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).