http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52091

Ira Rosen <irar at il dot ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |irar at il dot ibm.com

--- Comment #5 from Ira Rosen <irar at il dot ibm.com> 2012-02-02 13:22:53 UTC 
---
(In reply to comment #4)

I think that the problem here is that 
D.2030_19 = prephitmp.17_21 & 65535
is falsely initialized as reduction, while it isn't a reduction. The mistake
occurs because its def_stmt, 
prephitmp.17_21 = PHI <d.3_44(7), pretmp.16_28(2)> ,
is a phi node marked as double reduction:

<bb 3>:
  # f.6_36 = PHI <f.7_13(7), 0(2)>
  # prephitmp.17_21 = PHI <d.3_44(7), pretmp.16_28(2)> - double reduction phi
   ...
  D.2030_19 = prephitmp.17_21 & 65535; - not a reduction stmt
   ...
<bb 4>:
  # b.4_41 = PHI <b.5_11(5), 0(3)>
   ...
  d.3_9 = d_lsm.23_31 & 1;
   ...

<bb 6>:
  # d.3_44 = PHI <d.3_9(4)>       - double reduction stmt

I think we should fail to vectorize D.2030_19 = prephitmp.17_21 & 65535, or any
other non-phi/not vect_double_reduction_def stmt with a double reduction phi as
a def_stmt.

We can either check this in every vectorizable_* for every operand, like this:
Index: tree-vect-stmts.c
===================================================================
--- tree-vect-stmts.c   (revision 183125)
+++ tree-vect-stmts.c   (working copy)
@@ -3326,7 +3326,8 @@ vectorizable_operation (gimple stmt, gimple_stmt_i

   op0 = gimple_assign_rhs1 (stmt);
   if (!vect_is_simple_use_1 (op0, loop_vinfo, bb_vinfo,
-                            &def_stmt, &def, &dt[0], &vectype))
+                            &def_stmt, &def, &dt[0], &vectype)
+      || dt[0] == vect_double_reduction_def)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         fprintf (vect_dump, "use not simple.");


or pass stmt or stmt_info to vect_is_simple_use and check it there.


> OT, it is strange that we are creating a reduction for a loop which loops
> exactly as many times as there are units in the vector, that doesn't seem to 
> be
> profitable.
> 

Right, but doesn't cost model catch this?

Reply via email to