This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Ada broken on i686-linux (some progress)
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Cc: gcc at gcc dot gnu dot org, hubicka at ucw dot cz
- Date: Sun, 12 Sep 2004 21:46:37 +0200
- Subject: Re: Ada broken on i686-linux (some progress)
- References: <10409120155.AA28086@vlsi1.ultra.nyu.edu>
Hello,
> could you please check whether this patch helps?
>
> I can't say for sure it if "helps" or not, but this failure is
> still present:
this turned out not to be a sharing issue, but misshandling of
array_ref_element_size and array_ref_low_bound. The following
patch should hopefully get you at least a bit further.
Zdenek
Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.9
diff -c -3 -p -r2.9 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c 10 Sep 2004 08:56:36 -0000 2.9
--- tree-ssa-loop-ivopts.c 12 Sep 2004 19:35:03 -0000
*************** dump_iv (FILE *file, struct iv *iv)
*** 305,310 ****
--- 305,314 ----
print_generic_expr (file, iv->ssa_name, TDF_SLIM);
fprintf (file, "\n");
+ fprintf (file, " type ");
+ print_generic_expr (file, TREE_TYPE (iv->base), TDF_SLIM);
+ fprintf (file, "\n");
+
if (iv->step)
{
fprintf (file, " base ");
*************** dump_use (FILE *file, struct iv_use *use
*** 358,391 ****
gcc_unreachable ();
}
! fprintf (file, " in statement ");
! print_generic_expr (file, use->stmt, TDF_SLIM);
! fprintf (file, "\n");
!
! fprintf (file, " at position ");
! if (use->op_p)
! print_generic_expr (file, *use->op_p, TDF_SLIM);
! fprintf (file, "\n");
!
! if (iv->step)
! {
! fprintf (file, " base ");
! print_generic_expr (file, iv->base, TDF_SLIM);
! fprintf (file, "\n");
!
! fprintf (file, " step ");
! print_generic_expr (file, iv->step, TDF_SLIM);
! fprintf (file, "\n");
! }
! else
! {
! fprintf (file, " invariant ");
! print_generic_expr (file, iv->base, TDF_SLIM);
! fprintf (file, "\n");
! }
! fprintf (file, " related candidates ");
! dump_bitmap (file, use->related_cands);
}
/* Dumps information about the uses to FILE. */
--- 362,399 ----
gcc_unreachable ();
}
! fprintf (file, " in statement ");
! print_generic_expr (file, use->stmt, TDF_SLIM);
! fprintf (file, "\n");
!
! fprintf (file, " at position ");
! if (use->op_p)
! print_generic_expr (file, *use->op_p, TDF_SLIM);
! fprintf (file, "\n");
!
! fprintf (file, " type ");
! print_generic_expr (file, TREE_TYPE (iv->base), TDF_SLIM);
! fprintf (file, "\n");
!
! if (iv->step)
! {
! fprintf (file, " base ");
! print_generic_expr (file, iv->base, TDF_SLIM);
! fprintf (file, "\n");
!
! fprintf (file, " step ");
! print_generic_expr (file, iv->step, TDF_SLIM);
! fprintf (file, "\n");
! }
! else
! {
! fprintf (file, " invariant ");
! print_generic_expr (file, iv->base, TDF_SLIM);
! fprintf (file, "\n");
! }
! fprintf (file, " related candidates ");
! dump_bitmap (file, use->related_cands);
}
/* Dumps information about the uses to FILE. */
*************** dump_cand (FILE *file, struct iv_cand *c
*** 438,459 ****
break;
}
! if (iv->step)
! {
! fprintf (file, " base ");
! print_generic_expr (file, iv->base, TDF_SLIM);
! fprintf (file, "\n");
!
! fprintf (file, " step ");
! print_generic_expr (file, iv->step, TDF_SLIM);
! fprintf (file, "\n");
! }
! else
! {
! fprintf (file, " invariant ");
! print_generic_expr (file, iv->base, TDF_SLIM);
! fprintf (file, "\n");
! }
}
/* Returns the info for ssa version VER. */
--- 446,471 ----
break;
}
! fprintf (file, " type ");
! print_generic_expr (file, TREE_TYPE (iv->base), TDF_SLIM);
! fprintf (file, "\n");
!
! if (iv->step)
! {
! fprintf (file, " base ");
! print_generic_expr (file, iv->base, TDF_SLIM);
! fprintf (file, "\n");
!
! fprintf (file, " step ");
! print_generic_expr (file, iv->step, TDF_SLIM);
! fprintf (file, "\n");
! }
! else
! {
! fprintf (file, " invariant ");
! print_generic_expr (file, iv->base, TDF_SLIM);
! fprintf (file, "\n");
! }
}
/* Returns the info for ssa version VER. */
*************** idx_find_step (tree base, tree *idx, voi
*** 1150,1156 ****
{
struct ifs_ivopts_data *dta = data;
struct iv *iv;
! tree step, type, iv_type, iv_step;
if (TREE_CODE (*idx) != SSA_NAME)
return true;
--- 1162,1170 ----
{
struct ifs_ivopts_data *dta = data;
struct iv *iv;
! tree step, type, iv_type, iv_step, lbound;
! basic_block def_bb;
! struct loop *loop = dta->ivopts_data->current_loop;
if (TREE_CODE (*idx) != SSA_NAME)
return true;
*************** idx_find_step (tree base, tree *idx, voi
*** 1167,1173 ****
iv_type = TREE_TYPE (iv->base);
type = build_pointer_type (TREE_TYPE (base));
if (TREE_CODE (base) == ARRAY_REF)
! step = array_ref_element_size (base);
else
/* The step for pointer arithmetics already is 1 byte. */
step = build_int_cst (type, 1);
--- 1181,1210 ----
iv_type = TREE_TYPE (iv->base);
type = build_pointer_type (TREE_TYPE (base));
if (TREE_CODE (base) == ARRAY_REF)
! {
! step = array_ref_element_size (base);
! lbound = array_ref_low_bound (base);
!
! /* We only handle addresses whose step is an integer constant. */
! if (TREE_CODE (step) != INTEGER_CST)
! return false;
!
! /* We need the lower bound to be invariant in loop, since otherwise
! we are unable to initialize a new induction variable created
! in strength reduction -- we need to take the address of the
! reference in front of the loop. */
! if (is_gimple_min_invariant (lbound))
! ; /* Nothing to do. */
! else if (TREE_CODE (lbound) != SSA_NAME)
! return false;
! else
! {
! def_bb = bb_for_stmt (SSA_NAME_DEF_STMT (lbound));
! if (def_bb
! && flow_bb_inside_loop_p (loop, def_bb))
! return false;
! }
! }
else
/* The step for pointer arithmetics already is 1 byte. */
step = build_int_cst (type, 1);
*************** idx_find_step (tree base, tree *idx, voi
*** 1198,1207 ****
object is passed to it in DATA. */
static bool
! idx_record_use (tree base ATTRIBUTE_UNUSED, tree *idx,
void *data)
{
find_interesting_uses_op (data, *idx);
return true;
}
--- 1235,1249 ----
object is passed to it in DATA. */
static bool
! idx_record_use (tree base, tree *idx,
void *data)
{
find_interesting_uses_op (data, *idx);
+ if (TREE_CODE (base) == ARRAY_REF)
+ {
+ find_interesting_uses_op (data, array_ref_element_size (base));
+ find_interesting_uses_op (data, array_ref_low_bound (base));
+ }
return true;
}
*************** find_interesting_uses_stmt (struct ivopt
*** 1318,1329 ****
default: ;
}
! if (TREE_CODE_CLASS (TREE_CODE (lhs)) == 'r')
{
find_interesting_uses_address (data, stmt, &TREE_OPERAND (stmt, 0));
find_interesting_uses_op (data, rhs);
return;
}
}
if (TREE_CODE (stmt) == PHI_NODE
--- 1360,1381 ----
default: ;
}
! /* Handle memory = gimple_val. */
! if (TREE_CODE_CLASS (TREE_CODE (lhs)) == 'r'
! && is_gimple_val (rhs))
{
find_interesting_uses_address (data, stmt, &TREE_OPERAND (stmt, 0));
find_interesting_uses_op (data, rhs);
return;
}
+
+ /* TODO -- we should also handle address uses of type
+
+ memory = call (whatever);
+
+ and
+
+ call (memory). */
}
if (TREE_CODE (stmt) == PHI_NODE
*************** static tree
*** 1995,2004 ****
get_computation_at (struct loop *loop,
struct iv_use *use, struct iv_cand *cand, tree at)
{
! tree ubase = unsave_expr_now (use->iv->base);
! tree ustep = unsave_expr_now (use->iv->step);
! tree cbase = unsave_expr_now (cand->iv->base);
! tree cstep = unsave_expr_now (cand->iv->step);
tree utype = TREE_TYPE (ubase), ctype = TREE_TYPE (cbase);
tree uutype;
tree expr, delta;
--- 2047,2056 ----
get_computation_at (struct loop *loop,
struct iv_use *use, struct iv_cand *cand, tree at)
{
! tree ubase = use->iv->base;
! tree ustep = use->iv->step;
! tree cbase = cand->iv->base;
! tree cstep = cand->iv->step;
tree utype = TREE_TYPE (ubase), ctype = TREE_TYPE (cbase);
tree uutype;
tree expr, delta;
*************** iv_value (struct iv *iv, tree niter)
*** 2905,2911 ****
tree type = TREE_TYPE (iv->base);
niter = fold_convert (type, niter);
! val = fold (build2 (MULT_EXPR, type, iv->step, unsave_expr_now (niter)));
return fold (build2 (PLUS_EXPR, type, iv->base, val));
}
--- 2957,2963 ----
tree type = TREE_TYPE (iv->base);
niter = fold_convert (type, niter);
! val = fold (build2 (MULT_EXPR, type, iv->step, niter));
return fold (build2 (PLUS_EXPR, type, iv->base, val));
}
*************** rewrite_use_outer (struct ivopts_data *d
*** 4125,4130 ****
--- 4177,4183 ----
value = get_computation_at (data->current_loop,
use, cand, last_stmt (exit->src));
+ value = unshare_expr (value);
op = force_gimple_operand (value, &stmts, true, SSA_NAME_VAR (tgt));
/* If we will preserve the iv anyway and we would need to perform
Index: tree-ssa-loop-niter.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-niter.c,v
retrieving revision 2.7
diff -c -3 -p -r2.7 tree-ssa-loop-niter.c
*** tree-ssa-loop-niter.c 5 Sep 2004 15:24:15 -0000 2.7
--- tree-ssa-loop-niter.c 12 Sep 2004 19:35:03 -0000
*************** inverse (tree x, tree mask)
*** 84,105 ****
return rslt;
}
- /* Returns unsigned variant of TYPE. */
-
- tree
- unsigned_type_for (tree type)
- {
- return make_unsigned_type (TYPE_PRECISION (type));
- }
-
- /* Returns signed variant of TYPE. */
-
- static tree
- signed_type_for (tree type)
- {
- return make_signed_type (TYPE_PRECISION (type));
- }
-
/* Determine the number of iterations according to condition (for staying
inside loop) which compares two induction variables using comparison
operator CODE. The induction variable on left side of the comparison
--- 84,89 ----
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.426
diff -c -3 -p -r1.426 tree.c
*** tree.c 11 Sep 2004 21:14:38 -0000 1.426
--- tree.c 12 Sep 2004 19:35:07 -0000
*************** tree_fold_gcd (tree a, tree b)
*** 5939,5942 ****
--- 5939,5958 ----
}
}
+ /* Returns unsigned variant of TYPE. */
+
+ tree
+ unsigned_type_for (tree type)
+ {
+ return lang_hooks.types.unsigned_type (type);
+ }
+
+ /* Returns signed variant of TYPE. */
+
+ tree
+ signed_type_for (tree type)
+ {
+ return lang_hooks.types.signed_type (type);
+ }
+
#include "gt-tree.h"
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.619
diff -c -3 -p -r1.619 tree.h
*** tree.h 11 Sep 2004 21:14:39 -0000 1.619
--- tree.h 12 Sep 2004 19:35:09 -0000
*************** extern tree build_empty_stmt (void);
*** 2786,2791 ****
--- 2786,2792 ----
extern tree make_signed_type (int);
extern tree make_unsigned_type (int);
+ extern tree signed_type_for (tree);
extern tree unsigned_type_for (tree);
extern void initialize_sizetypes (bool);
extern void set_sizetype (tree);