tree.h (contains_packed_reference): Mention ARRAY_RANGE_REF in head comment.

* 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.

From-SVN: r141065
This commit is contained in:
Eric Botcazou 2008-10-11 19:48:47 +00:00 committed by Eric Botcazou
parent cb0dee885c
commit 9f7ccf6944
7 changed files with 74 additions and 17 deletions

View file

@ -1,3 +1,21 @@
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>

View file

@ -6079,9 +6079,9 @@ get_inner_reference (tree exp, HOST_WIDE_INT *pbitsize,
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)
@ -6121,7 +6121,7 @@ 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)
@ -6148,7 +6148,7 @@ 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)
@ -6169,7 +6169,7 @@ 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)

View file

@ -1,3 +1,8 @@
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

View file

@ -0,0 +1,21 @@
-- { 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;

View file

@ -0,0 +1,7 @@
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;

View file

@ -632,7 +632,7 @@ static bool
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;
@ -1356,8 +1356,13 @@ idx_find_step (tree base, tree *idx, void *data)
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);
@ -1381,7 +1386,7 @@ idx_find_step (tree base, tree *idx, void *data)
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);
@ -1418,7 +1423,7 @@ idx_record_use (tree base, tree *idx,
{
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));
@ -1918,6 +1923,7 @@ strip_offset_1 (tree expr, bool inside_addr, bool top_compref,
return fold_convert (orig_type, expr);
case ARRAY_REF:
case ARRAY_RANGE_REF:
if (!inside_addr)
return orig_expr;
@ -5180,7 +5186,7 @@ idx_remove_ssa_names (tree base, tree *idx,
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

View file

@ -4552,24 +4552,24 @@ extern tree get_inner_reference (tree, HOST_WIDE_INT *, HOST_WIDE_INT *,
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);