]> gcc.gnu.org Git - gcc.git/commitdiff
trans.c (push_range_check_info): Replace early test with assertion.
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 24 Nov 2014 08:18:40 +0000 (08:18 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 24 Nov 2014 08:18:40 +0000 (08:18 +0000)
* 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.

From-SVN: r217998

gcc/ada/ChangeLog
gcc/ada/gcc-interface/trans.c
gcc/ada/gcc-interface/utils.c
gcc/ada/gcc-interface/utils2.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/opt45.adb [new file with mode: 0644]

index 3cde2d8d434b463f11e79d7a7736a1add5aca277..c8568f72ee475696b07fd0bae52b039cf92fa817 100644 (file)
@@ -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>
 
        * gcc-interface/trans.c (Call_to_gnu): Strip unchecked conversions on
index 1888c194006e44a7b606e285cc03bf5f766520e9..11aca57239f0cc08b8674a6cfefda414ec31c20c 100644 (file)
@@ -2569,9 +2569,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)
@@ -2580,6 +2577,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--)
@@ -5175,6 +5174,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
index 32f0012c0c83e1669772bfd34e63d640cf283565..1b1473723c6e48d039962289bf54742d998f41c6 100644 (file)
@@ -3860,8 +3860,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);
index e853e1f55f2f1d3c232fe22608ddd0d9e4b85f8b..1296a4996119801f11518dc333b4ece126369769 100644 (file)
@@ -2780,7 +2780,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);
@@ -2836,7 +2842,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
index 084e45c24c9e1216378434a4188545b4c15bbb20..76d6653ca2ac592046ad978fd70c7a457d94bc6c 100644 (file)
@@ -1,3 +1,7 @@
+2014-11-24  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/opt45.adb: New test.
+
 2014-11-24  Tobias Burnus  <burnus@net-b.de>
 
        * gfortran.dg/dollar_sym_3.f: Update dg-error.
diff --git a/gcc/testsuite/gnat.dg/opt45.adb b/gcc/testsuite/gnat.dg/opt45.adb
new file mode 100644 (file)
index 0000000..f75e46e
--- /dev/null
@@ -0,0 +1,38 @@
+-- { dg-do compile }\r
+-- { dg-options "-O3" }\r
+\r
+procedure Opt45 is\r
+\r
+  type Index_T is mod 2 ** 32;\r
+  for Index_T'Size use 32;\r
+  for Index_T'Alignment use 1;\r
+\r
+  type Array_T is array (Index_T range <>) of Natural;\r
+  type Array_Ptr_T is access all Array_T;\r
+\r
+  My_Array_1 : aliased Array_T := (1, 2);\r
+  My_Array_2 : aliased Array_T := (3, 4);\r
+\r
+  Array_Ptr : Array_Ptr_T := null;\r
+  Index : Index_T := Index_T'First;\r
+\r
+  My_Value : Natural := Natural'First;\r
+\r
+  procedure Proc (Selection : Positive) is\r
+  begin\r
+    if Selection = 1 then\r
+      Array_Ptr := My_Array_1'Access;\r
+      Index := My_Array_1'First;\r
+    else\r
+      Array_Ptr := My_Array_2'Access;\r
+      Index := My_Array_2'First;\r
+    end if;\r
+\r
+    if My_Value = Natural'First then\r
+      My_Value := Array_Ptr.all (Index);\r
+    end if;\r
+  end;\r
+\r
+begin\r
+  Proc (2);\r
+end;\r
This page took 0.09944 seconds and 5 git commands to generate.