+2008-10-11 Eric Botcazou <ebotcazou@adacore.com>
+
+ * tree.h (contains_packed_reference): Mention ARRAY_RANGE_REF in
+ head comment.
+ (array_ref_element_size): Likewise.
+ (array_ref_low_bound): Likewise.
+ (array_ref_up_bound): Likewise.
+ * expr.c (contains_packed_reference): Likewise.
+ (array_ref_element_size): Likewise.
+ (array_ref_low_bound): Likewise.
+ (array_ref_up_bound): Likewise.
+ * tree-ssa-loop-ivopts.c (idx_contains_abnormal_ssa_name_p): Deal
+ with ARRAY_RANGE_REF.
+ (idx_find_step): Likewise.
+ (idx_record_use): Likewise.
+ (strip_offset_1): Likewise.
+ (idx_remove_ssa_names): Likewise.
+
2008-10-11 Uros Bizjak <ubizjak@gmail.com>
Andi Kleen <ak@linux.intel.com>
return exp;
}
-/* Given an expression EXP that may be a COMPONENT_REF or an ARRAY_REF,
- look for whether EXP or any nested component-refs within EXP is marked
- as PACKED. */
+/* Given an expression EXP that may be a COMPONENT_REF, an ARRAY_REF or an
+ ARRAY_RANGE_REF, look for whether EXP or any nested component-refs within
+ EXP is marked as PACKED. */
bool
contains_packed_reference (const_tree exp)
}
/* Return a tree of sizetype representing the size, in bytes, of the element
- of EXP, an ARRAY_REF. */
+ of EXP, an ARRAY_REF or an ARRAY_RANGE_REF. */
tree
array_ref_element_size (tree exp)
}
/* Return a tree representing the lower bound of the array mentioned in
- EXP, an ARRAY_REF. */
+ EXP, an ARRAY_REF or an ARRAY_RANGE_REF. */
tree
array_ref_low_bound (tree exp)
}
/* Return a tree representing the upper bound of the array mentioned in
- EXP, an ARRAY_REF. */
+ EXP, an ARRAY_REF or an ARRAY_RANGE_REF. */
tree
array_ref_up_bound (tree exp)
+2008-10-11 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gnat.dg/loop_optimization5.adb: New test.
+ * gnat.dg/loop_optimization5_pkg.adb: New helper.
+
2008-10-11 Paul Thomas <pault@gcc.gnu.org>
PR fortran/37794
--- /dev/null
+-- { dg-do compile }
+-- { dg-options "-O -gnatp" }
+
+with Loop_Optimization5_Pkg; use Loop_Optimization5_Pkg;
+
+procedure Loop_Optimization5 is
+ Str : constant String := "12345678";
+ Cmd : constant String := Init;
+ StartP : Positive := Cmd'First;
+ StartS : Positive := Cmd'Last + 1;
+ EndP : Natural := StartP - 1;
+ Full_Cmd : String_Access;
+begin
+ for J in StartP .. Cmd'Last - Str'Length + 1 loop
+ if Cmd (J .. J + Str'Length - 1) = Str then
+ EndP := J - 1;
+ exit;
+ end if;
+ end loop;
+ Full_Cmd := Locate (Cmd (StartP .. EndP));
+end;
--- /dev/null
+package Loop_Optimization5_Pkg is
+
+ type String_Access is access all String;
+ function Init return String;
+ function Locate (S : String) return String_Access;
+
+end Loop_Optimization5_Pkg;
idx_contains_abnormal_ssa_name_p (tree base, tree *index,
void *data ATTRIBUTE_UNUSED)
{
- if (TREE_CODE (base) == ARRAY_REF)
+ if (TREE_CODE (base) == ARRAY_REF || TREE_CODE (base) == ARRAY_RANGE_REF)
{
if (abnormal_ssa_name_p (TREE_OPERAND (base, 2)))
return false;
reference out of the loop (in order to take its address in strength
reduction). In order for this to work we need both lower bound
and step to be loop invariants. */
- if (TREE_CODE (base) == ARRAY_REF)
+ if (TREE_CODE (base) == ARRAY_REF || TREE_CODE (base) == ARRAY_RANGE_REF)
{
+ /* Moreover, for a range, the size needs to be invariant as well. */
+ if (TREE_CODE (base) == ARRAY_RANGE_REF
+ && !expr_invariant_in_loop_p (loop, TYPE_SIZE (TREE_TYPE (base))))
+ return false;
+
step = array_ref_element_size (base);
lbound = array_ref_low_bound (base);
if (integer_zerop (iv->step))
return true;
- if (TREE_CODE (base) == ARRAY_REF)
+ if (TREE_CODE (base) == ARRAY_REF || TREE_CODE (base) == ARRAY_RANGE_REF)
{
step = array_ref_element_size (base);
{
struct ivopts_data *data = (struct ivopts_data *) vdata;
find_interesting_uses_op (data, *idx);
- if (TREE_CODE (base) == ARRAY_REF)
+ if (TREE_CODE (base) == ARRAY_REF || TREE_CODE (base) == ARRAY_RANGE_REF)
{
find_interesting_uses_op (data, array_ref_element_size (base));
find_interesting_uses_op (data, array_ref_low_bound (base));
return fold_convert (orig_type, expr);
case ARRAY_REF:
+ case ARRAY_RANGE_REF:
if (!inside_addr)
return orig_expr;
if (TREE_CODE (*idx) == SSA_NAME)
*idx = SSA_NAME_VAR (*idx);
- if (TREE_CODE (base) == ARRAY_REF)
+ if (TREE_CODE (base) == ARRAY_REF || TREE_CODE (base) == ARRAY_RANGE_REF)
{
op = &TREE_OPERAND (base, 2);
if (*op
tree *, enum machine_mode *, int *, int *,
bool);
-/* Given an expression EXP that may be a COMPONENT_REF or an ARRAY_REF,
- look for whether EXP or any nested component-refs within EXP is marked
- as PACKED. */
+/* Given an expression EXP that may be a COMPONENT_REF, an ARRAY_REF or an
+ ARRAY_RANGE_REF, look for whether EXP or any nested component-refs within
+ EXP is marked as PACKED. */
extern bool contains_packed_reference (const_tree exp);
/* Return a tree of sizetype representing the size, in bytes, of the element
- of EXP, an ARRAY_REF. */
+ of EXP, an ARRAY_REF or an ARRAY_RANGE_REF. */
extern tree array_ref_element_size (tree);
/* Return a tree representing the lower bound of the array mentioned in
- EXP, an ARRAY_REF. */
+ EXP, an ARRAY_REF or an ARRAY_RANGE_REF. */
extern tree array_ref_low_bound (tree);
/* Return a tree representing the upper bound of the array mentioned in
- EXP, an ARRAY_REF. */
+ EXP, an ARRAY_REF or an ARRAY_RANGE_REF. */
extern tree array_ref_up_bound (tree);