public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch] Avoid is_simple_use bug in vectorizable_live_operation
@ 2015-10-26 12:54 Alan Hayward
  2015-10-26 13:42 ` Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Hayward @ 2015-10-26 12:54 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 874 bytes --]

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.


2015-09-07  Alan Hayward  alan.hayward@arm.com
	* tree-vect-looop.c (vectorizable_live_operation): localize variable.


Cheers,
Alan


[-- Attachment #2: avoid_issimple.patch --]
[-- Type: application/octet-stream, Size: 668 bytes --]

diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 8c23972022d92dbfdb5742c32740233fc24684aa..6c0a919c6b056bc2588904a748fcd3ee8441cd5d 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -5994,7 +5994,6 @@ vectorizable_live_operation (gimple stmt,
   tree op;
   tree def;
   gimple def_stmt;
-  enum vect_def_type dt;
   enum tree_code code;
   enum gimple_rhs_class rhs_class;
 
@@ -6059,6 +6058,8 @@ vectorizable_live_operation (gimple stmt,
 
   for (i = 0; i < op_type; i++)
     {
+      enum vect_def_type dt = vect_uninitialized_def;
+
       if (rhs_class == GIMPLE_SINGLE_RHS)
 	op = TREE_OPERAND (gimple_op (stmt, 1), i);
       else

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

end of thread, other threads:[~2015-10-27 13:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 12:54 [Patch] Avoid is_simple_use bug in vectorizable_live_operation Alan Hayward
2015-10-26 13:42 ` Richard Biener
2015-10-26 17:15   ` Alan Hayward
2015-10-27 11:37     ` Richard Biener
2015-10-27 13:45       ` Alan Hayward
2015-10-27 13:52         ` 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).