This is an internal error in for_each_index at -O:
+===========================GNAT BUG DETECTED==============================+
| 4.8.0 20121208 (experimental) [trunk revision 194319] (x86_64-suse-linux)
GCC error:|
| in for_each_index, at tree-ssa-loop-im.c:324 |
| Error detected around vect9.adb:45:1|
The callback is invoked on a vector CONST_DECL and stops. That's an unusual
situation (the CONST_DECL is wrapped up in a VIEW_CONVERT_EXPR to array type)
but IMO there is no reason to accept other DECLs and stop on CONST_DECLs.
Tested on x86_64-suse-linux, applied on the mainline as obvious.
2012-12-08 Eric Botcazou <ebotca...@adacore.com>
* tree-ssa-loop-im.c (for_each_index) <CONST_DECL>: New case.
2012-12-08 Eric Botcazou <ebotca...@adacore.com>
* gnat.dg/vect9.ad[sb]: New test.
* gnat.dg/vect9_pkg.ads: New helper.
--
Eric Botcazou
Index: tree-ssa-loop-im.c
===================================================================
--- tree-ssa-loop-im.c (revision 194319)
+++ tree-ssa-loop-im.c (working copy)
@@ -291,6 +291,7 @@ for_each_index (tree *addr_p, bool (*cbc
case VAR_DECL:
case PARM_DECL:
+ case CONST_DECL:
case STRING_CST:
case RESULT_DECL:
case VECTOR_CST:
-- { dg-do compile }
-- { dg-options "-O" }
package body Vect9 is
function Cmove
(X : in Unit;
Y : in Unit;
If_True : in Unit;
If_False : in Unit)
return Unit
is
Res : Unit;
begin
for P in Unit'Range loop
if X (P) >= Y (P) then
Res (P) := If_True (P);
else
Res (P) := If_False (P);
end if;
end loop;
return Res;
end;
pragma Inline_Always (Cmove);
procedure Proc
(This : in Rec;
CV : in Unit_Vector;
Data : in out Unit_Vector)
is
begin
for Index in Data'Range loop
Data (Index) := Mul (Zero_Unit, Zero_Unit);
declare
Addend : constant Unit
:= Cmove (CV (Index), Zero_Unit, Zero_Unit, Zero_Unit) ;
begin
Data (Index) := Data(Index) + Addend;
end;
This.Data (Index) := Data (Index);
end loop;
end;
end Vect9;
with Vect9_Pkg; use Vect9_Pkg;
package Vect9 is
type Rec is record
Data : Vector_Access;
end record;
procedure Proc
(This : in Rec;
CV : in Unit_Vector;
Data : in out Unit_Vector);
end Vect9;
package Vect9_Pkg is
type Unit is array (1 .. 4) of Float;
for Unit'Alignment use 32;
pragma Machine_Attribute (Unit, "vector_type");
pragma Machine_Attribute (Unit, "may_alias");
Zero_Unit : constant Unit := (others => 0.0);
function Mul (X : in Unit; Y : in Unit) return Unit;
function "+"(Left, Right : Unit) return Unit;
function "*"(Left, Right : Unit) return Unit;
type Unit_Vector is array (Positive range <>) of Unit;
type Vector_Access is access all Unit_Vector;
end Vect9_Pkg;