This is a regression present on the mainline and 6 branch and introduced by
the new factor_out_conditional_conversion function:
eric@polaris:~/build/gcc/native> gcc/xgcc -Bgcc -S opt55.adb -O
+===========================GNAT BUG DETECTED==============================+
| 7.0.0 20160523 (experimental) [trunk revision 236576] (x86_64-suse-linux)
GCC error:|
| in make_ssa_name_fn, at tree-ssanames.c:266 |
| Error detected around opt55.adb:15:4
The function is trying to create a SSA_NAME of a RECORD_TYPE because it just
stripped a VIEW_CONVERT_EXPR created by SRA:
_1 = VIEW_CONVERT_EXPR<float>(VIEW_CONVERT_EXPR<struct
opt55__f__S3b>(*c_4(D)).d1);
Fixed by bailing out if the new type is not is_gimple_reg_type. The patch
also removes a test which is trivially redundant (is_gimple_assign is subsumed
into gimple_assign_cast_p).
Tested on x86_64-suse-linux, applied on the mainline and 6 branch as obvious.
2016-05-25 Eric Botcazou <ebotca...@adacore.com>
* tree-ssa-phiopt.c (factor_out_conditional_conversion): Remove
redundant test and bail out if the type of the new operand is not
a GIMPLE register type after stripping a VIEW_CONVERT_EXPR.
2016-05-25 Eric Botcazou <ebotca...@adacore.com>
* gnat.dg/opt55.ad[sb]: New test.
--
Eric Botcazou
Index: tree-ssa-phiopt.c
===================================================================
--- tree-ssa-phiopt.c (revision 236576)
+++ tree-ssa-phiopt.c (working copy)
@@ -438,15 +438,18 @@ factor_out_conditional_conversion (edge
/* Check if arg0 is an SSA_NAME and the stmt which defines arg0 is
a conversion. */
arg0_def_stmt = SSA_NAME_DEF_STMT (arg0);
- if (!is_gimple_assign (arg0_def_stmt)
- || !gimple_assign_cast_p (arg0_def_stmt))
+ if (!gimple_assign_cast_p (arg0_def_stmt))
return NULL;
/* Use the RHS as new_arg0. */
convert_code = gimple_assign_rhs_code (arg0_def_stmt);
new_arg0 = gimple_assign_rhs1 (arg0_def_stmt);
if (convert_code == VIEW_CONVERT_EXPR)
- new_arg0 = TREE_OPERAND (new_arg0, 0);
+ {
+ new_arg0 = TREE_OPERAND (new_arg0, 0);
+ if (!is_gimple_reg_type (TREE_TYPE (new_arg0)))
+ return NULL;
+ }
if (TREE_CODE (arg1) == SSA_NAME)
{
-- { dg-do compile }
-- { dg-options "-O" }
package body Opt55 is
function Cond (B : Boolean; If_True, If_False : Date) return Date is
begin
if B then
return If_True;
else
return If_False;
end if;
end;
function F (C : Rec2; B : Boolean) return Date is
begin
return Cond (B, C.D1, C.D2);
end;
end Opt55;
package Opt55 is
type Date is record
D : Float;
end record;
type Rec1 (Kind : Boolean := False) is record
case Kind is
when True => N : Natural;
when False => null;
end case;
end record;
type Rec2 (D : Positive) is record
R : Rec1;
D1 : Date;
D2 : Date;
end record;
function F (C : Rec2; B : Boolean) return Date;
end Opt55;