summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ada/ChangeLog10
-rw-r--r--gcc/ada/gcc-interface/trans.c6
-rw-r--r--gcc/ada/gcc-interface/utils.c3
-rw-r--r--gcc/ada/gcc-interface/utils2.c10
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/opt45.adb38
6 files changed, 64 insertions, 7 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index fcdc4e353c0..ea5a7bebf5a 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,13 @@
+2014-11-24 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/trans.c (push_range_check_info): Replace early test
+ with assertion.
+ (Raise_Error_to_gnu): Do not call push_range_check_info if the loop
+ stack is empty.
+ * gcc-interface/utils.c (convert_to_fat_pointer): Fix formatting.
+ * gcc-interface/utils2.c (gnat_invariant_expr): Deal with padded types
+ and revert latest change.
+
2014-11-22 Eric Botcazou <ebotcazou@adacore.com>
Backport from mainline
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 03bf098b0e3..30a166611e5 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -2424,9 +2424,6 @@ push_range_check_info (tree var)
struct loop_info_d *iter = NULL;
unsigned int i;
- if (vec_safe_is_empty (gnu_loop_stack))
- return NULL;
-
var = remove_conversions (var, false);
if (TREE_CODE (var) != VAR_DECL)
@@ -2435,6 +2432,8 @@ push_range_check_info (tree var)
if (decl_function_context (var) != current_function_decl)
return NULL;
+ gcc_assert (vec_safe_length (gnu_loop_stack) > 0);
+
for (i = vec_safe_length (gnu_loop_stack) - 1;
vec_safe_iterate (gnu_loop_stack, i, &iter);
i--)
@@ -5165,6 +5164,7 @@ Raise_Error_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p)
the original checks reinstated, and a run time selection.
The former loop will be suitable for vectorization. */
if (flag_unswitch_loops
+ && !vec_safe_is_empty (gnu_loop_stack)
&& (!gnu_low_bound
|| (gnu_low_bound = gnat_invariant_expr (gnu_low_bound)))
&& (!gnu_high_bound
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 15b72366bf5..820d2cec979 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -4371,8 +4371,7 @@ convert_to_fat_pointer (tree type, tree expr)
{
/* The template type can still be dummy at this point so we build an
empty constructor. The middle-end will fill it in with zeros. */
- t = build_constructor (template_type,
- NULL);
+ t = build_constructor (template_type, NULL);
TREE_CONSTANT (t) = TREE_STATIC (t) = 1;
null_bounds = build_unary_op (ADDR_EXPR, NULL_TREE, t);
SET_TYPE_NULL_BOUNDS (ptr_template_type, null_bounds);
diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c
index dd4151b5bc5..da52f418585 100644
--- a/gcc/ada/gcc-interface/utils2.c
+++ b/gcc/ada/gcc-interface/utils2.c
@@ -2784,7 +2784,13 @@ gnat_invariant_expr (tree expr)
|| (TREE_CODE (expr) == VAR_DECL && TREE_READONLY (expr)))
&& decl_function_context (expr) == current_function_decl
&& DECL_INITIAL (expr))
- expr = remove_conversions (DECL_INITIAL (expr), false);
+ {
+ expr = DECL_INITIAL (expr);
+ /* Look into CONSTRUCTORs built to initialize padded types. */
+ if (TYPE_IS_PADDING_P (TREE_TYPE (expr)))
+ expr = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (expr))), expr);
+ expr = remove_conversions (expr, false);
+ }
if (TREE_CONSTANT (expr))
return fold_convert (type, expr);
@@ -2840,7 +2846,7 @@ object:
if (!TREE_READONLY (t))
return NULL_TREE;
- if (TREE_CODE (t) == CONSTRUCTOR || TREE_CODE (t) == PARM_DECL)
+ if (TREE_CODE (t) == PARM_DECL)
return fold_convert (type, expr);
if (TREE_CODE (t) == VAR_DECL
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6062ff8b7f6..e668010b3cb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-11-24 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/opt45.adb: New test.
+
2014-11-22 Oleg Endo <olegendo@gcc.gnu.org>
Backport from mainline
diff --git a/gcc/testsuite/gnat.dg/opt45.adb b/gcc/testsuite/gnat.dg/opt45.adb
new file mode 100644
index 00000000000..f75e46ed42d
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/opt45.adb
@@ -0,0 +1,38 @@
+-- { dg-do compile }
+-- { dg-options "-O3" }
+
+procedure Opt45 is
+
+ type Index_T is mod 2 ** 32;
+ for Index_T'Size use 32;
+ for Index_T'Alignment use 1;
+
+ type Array_T is array (Index_T range <>) of Natural;
+ type Array_Ptr_T is access all Array_T;
+
+ My_Array_1 : aliased Array_T := (1, 2);
+ My_Array_2 : aliased Array_T := (3, 4);
+
+ Array_Ptr : Array_Ptr_T := null;
+ Index : Index_T := Index_T'First;
+
+ My_Value : Natural := Natural'First;
+
+ procedure Proc (Selection : Positive) is
+ begin
+ if Selection = 1 then
+ Array_Ptr := My_Array_1'Access;
+ Index := My_Array_1'First;
+ else
+ Array_Ptr := My_Array_2'Access;
+ Index := My_Array_2'First;
+ end if;
+
+ if My_Value = Natural'First then
+ My_Value := Array_Ptr.all (Index);
+ end if;
+ end;
+
+begin
+ Proc (2);
+end;