* [Ada] Fix ICE on loop at -O3
@ 2015-03-16 10:09 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2015-03-16 10:09 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 527 bytes --]
This fixes a regression present on all active branches at -O3, caused by a
call to fold_convert with an aggregate type.
Tested on x86_64-suse-linux, applied on all active branches.
2015-03-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/utils2.c (gnat_invariant_expr): Return null if the type
of the expression ends up being composite.
2015-03-16 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/loop_optimization18.ad[sb]: New test.
* gnat.dg/loop_optimization18_pkg.ads: New helper.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 631 bytes --]
Index: gcc-interface/utils2.c
===================================================================
--- gcc-interface/utils2.c (revision 221407)
+++ gcc-interface/utils2.c (working copy)
@@ -2805,6 +2805,12 @@ gnat_invariant_expr (tree expr)
expr = remove_conversions (expr, false);
}
+ /* We are only interested in scalar types at the moment and, even if we may
+ have gone through padding types in the above loop, we must be back to a
+ scalar value at this point. */
+ if (AGGREGATE_TYPE_P (TREE_TYPE (expr)))
+ return NULL_TREE;
+
if (TREE_CONSTANT (expr))
return fold_convert (type, expr);
[-- Attachment #3: loop_optimization18_pkg.ads --]
[-- Type: text/x-adasrc, Size: 345 bytes --]
with Unchecked_Conversion;
package Loop_Optimization18_Pkg is
type Arr is array (Integer range <>) of Natural;
type Rec (UB : Integer) is record
L : Arr (1 .. UB);
end record;
type Byte_Array_Type is new String (1..4);
function Conv is new Unchecked_Conversion (Byte_Array_Type, Integer);
end Loop_Optimization18_Pkg;
[-- Attachment #4: loop_optimization18.ads --]
[-- Type: text/x-adasrc, Size: 165 bytes --]
with Loop_Optimization18_Pkg; use Loop_Optimization18_Pkg;
package Loop_Optimization18 is
procedure Proc (Message : Byte_Array_Type);
end Loop_Optimization18;
[-- Attachment #5: loop_optimization18.adb --]
[-- Type: text/x-adasrc, Size: 291 bytes --]
-- { dg-do compile }
-- { dg-options "-O3" }
package body Loop_Optimization18 is
procedure Proc (Message : Byte_Array_Type) is
R : Rec (Conv (Message));
begin
for Division in 1 .. R.UB loop
R.L (Division) := 0;
end loop;
end;
end Loop_Optimization18;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-03-16 10:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 10:09 [Ada] Fix ICE on loop at -O3 Eric Botcazou
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).