This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
tree-ssa question - replacing data-refs in stmts
- From: Dorit Naishlos <DORIT at il dot ibm dot com>
- To: gcc at gcc dot gnu dot org
- Cc: Diego Novillo <dnovillo at redhat dot com>
- Date: Wed, 5 May 2004 01:15:15 +0300
- Subject: tree-ssa question - replacing data-refs in stmts
Hi,
I wrote a transformation that replaces pointer arithmetic with array-refs.
For example, in the following sequence:
1. i.13_7 = (unsigned int)i_1;
2. T.14_8 = i.13_7 * 4;
3. T.15_9 = (float *)T.14_8;
4. T.17_14 = T.15_9 + pb_4;
5. T.18_15 = *T.17_14;
stmt 5 becomes:
5. T.18_15 = (*pb_4)[ivtmp.44_34];
This is supposed to simplify data references for the vectorizer, and allow
it to focus only on array_refs.
My transformation scheme worked, by chance (?), on a few examples, but
failed on others - looks like because the vdefs/vuses were not always
computed properly.
I guess I need some guidance with how to properly replace a data reference
in a stmt?
Below is the code snippet that performs this transformation.
I use Sebastian's analyzer to get the access function of a pointer. If it
is "simple enough", I convert it to an array_ref.
For simplicity, I started with trying to handle only pointers which
initial_condition ('init') is an SSA_NAME (like 'pb_4' in the example
above):
if (TREE_CODE (memref) == INDIRECT_REF)
{
.... /* some checks */
innertype = TREE_TYPE (memref);
base = init; /* 'initial_condition'; FORNOW an SSA_NAME */
create_iv (integer_zero_node, integer_one_node, NULL_TREE, loop,
&loop_exit_bsi, false, &indx_before_incr, &indx_after_incr);
/* CHECKME: what is the correct way to create array type? unless I
explicitly set TYPE_ALIGN, it is set to some default value 8. */
array_type = build_array_type (innertype, 0);
TYPE_ALIGN (array_type) = TYPE_ALIGN (innertype);
ref = build (ARRAY_REF, innertype,
build1 (INDIRECT_REF, array_type, base), indx_before_incr);
/* CHECKME: right way to modify a memref in a stmt? */
if (vuses) /* it's a load */
TREE_OPERAND (stmt, 1) = ref;
else /* it's a store */
TREE_OPERAND (stmt, 0) = ref;
modify_stmt (stmt);
mark_new_vars_to_rename (stmt, vars_to_rename);
}
It didn't help when I called
bitmap_set_bit (vars_to_rename, var_ann (SSA_NAME_VAR (use))->uid);
for each of the vuses/vdefs of the stmt.
what's the right way to do it?
thanks,
dorit