This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix ICE at -O3 in the vectorizer


The attached testcase causes a checking failure at -O3 in the vectorizer:

eric@atlantis:> ./gnat1 -quiet p.adb -O3 -msse
+===========================GNAT BUG DETECTED==============================+
| 4.5.0 20091020 (experimental) [trunk revision 153008] (i586-suse-linux-gnu) 
GCC error:|
| gimple check: expected gimple_assign(error_mark), have                   |
|     gimple_call(block) in gimple_assign_lhs, at gimple.h:1682      

(gdb) frame 3
#3  0x08cbbd99 in exist_non_indexing_operands_for_use_p (use=0xf7d9c6e8,
    stmt=0xf7cd5880) 
at /home/eric/gnat/gnat-head/src/gcc/tree-vect-stmts.c:195
195       if (TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME)
(gdb) p debug_gimple_stmt(stmt)
# .MEM_7 = VDEF <.MEM_12>
result[i_11]{lb: 1 sz: 4} = q__conv ((*a_3(D))[i_11]{lb: 1 sz: 4}); [return 
slot optimization]

The code expects a GIMPLE_ASSIGN statement whereas it has a GIMPLE_CALL.

Fixed by moving up the existing gimple_assign_copy_p check.

Tested on i586-suse-linux, applied on the mainline as obvious.


2009-10-21  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-vect-stmts.c (exist_non_indexing_operands_for_use_p): Tweak
	order of checks.


2009-10-21  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/loop_optimization7.ad[sb]: New test.
	* gnat.dg/loop_optimization7_pkg.ads: New helper.


-- 
Eric Botcazou
Index: tree-vect-stmts.c
===================================================================
--- tree-vect-stmts.c	(revision 153008)
+++ tree-vect-stmts.c	(working copy)
@@ -172,13 +172,13 @@ exist_non_indexing_operands_for_use_p (t
 {
   tree operand;
   stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
- 
+
   /* USE corresponds to some operand in STMT. If there is no data
      reference in STMT, then any operand that corresponds to USE
      is not indexing an array.  */
   if (!STMT_VINFO_DATA_REF (stmt_info))
     return true;
- 
+
   /* STMT has a data_ref. FORNOW this means that its of one of
      the following forms:
      -1- ARRAY_REF = var
@@ -191,14 +191,12 @@ exist_non_indexing_operands_for_use_p (t
 
      Therefore, all we need to check is if STMT falls into the
      first case, and whether var corresponds to USE.  */
- 
-  if (TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME)
-    return false;
 
   if (!gimple_assign_copy_p (stmt))
     return false;
+  if (TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME)
+    return false;
   operand = gimple_assign_rhs1 (stmt);
-
   if (TREE_CODE (operand) != SSA_NAME)
     return false;
 
-- { dg-do compile }
-- { dg-options "-O3" }
-- { dg-options "-O3 -msse" { target i?86-*-* x86_64-*-* } }

package body Loop_Optimization7 is

  function Conv (A : Arr) return Arr is
    Result : Arr;
  begin
    for I in A'Range loop
      Result (I) := Conv (A (I));
    end loop;
    return Result;
  end;

end Loop_Optimization7;
with Loop_Optimization7_Pkg; use Loop_Optimization7_Pkg;

package Loop_Optimization7  is

   type Arr is array (1..8) of Rec;

   function Conv (A : Arr) return Arr;

end Loop_Optimization7;
package Loop_Optimization7_Pkg is
  pragma Pure;

  type Rec is record
    F : Float;
  end record;

  function Conv (Trig : Rec) return Rec;

end Loop_Optimization7_Pkg;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]