[tree-ssa] tree-mustalias fix
Jan Hubicka
jh@suse.cz
Fri Dec 19 19:39:00 GMT 2003
Hi,
followint testsuite testcase:
f (unsigned short Z[48])
{
int j;
unsigned short t1, t2, t3, T[48];
unsigned short *p = T + 48;
for (j = 1; j < 8; j++)
{
t1 = *Z++;
*--p = *Z++;
*--p = t1;
t1 = inv(*Z++);
t2 = -*Z++;
t3 = -*Z++;
*--p = inv(*Z++);
*--p = t2;
*--p = t3;
*--p = t1;
}
}
Produce following SSA representation at mustalias:
;; Function f (f)
f (Z)
{
short unsigned int * p;
short unsigned int T[48];
short unsigned int t3;
short unsigned int t2;
short unsigned int t1;
int j;
short unsigned int T.7;
int T.6;
short int T.5;
short int T.4;
int T.3;
int T.2;
short unsigned int T.1;
<bb 0>:
goto <bb 2> (<L1>);
<L0>:;
t1_19 = *Z_5;
Z_20 = Z_5 + 2B;
p_21 = p_1 - 2B;
T.1_22 = *Z_20;
*p_21 = T.1_22;
Z_24 = Z_5 + 4B;
p_25 = p_1 - 4B;
*p_25 = t1_19;
T.1_27 = *Z_24;
T.2_28 = (int)T.1_27;
T.3_29 = inv (T.2_28);
t1_31 = (short unsigned int)T.3_29;
Z_32 = Z_5 + 6B;
T.1_33 = *Z_32;
T.4_34 = (short int)T.1_33;
T.5_35 = -T.4_34;
t2_36 = (short unsigned int)T.5_35;
Z_37 = Z_5 + 8B;
T.1_38 = *Z_37;
T.4_39 = (short int)T.1_38;
T.5_40 = -T.4_39;
t3_41 = (short unsigned int)T.5_40;
Z_42 = Z_5 + 10B;
p_43 = p_1 - 6B;
T.1_44 = *Z_42;
T.2_45 = (int)T.1_44;
T.6_46 = inv (T.2_45);
T.7_48 = (short unsigned int)T.6_46;
*p_43 = T.7_48;
Z_50 = Z_5 + 12B;
p_51 = p_1 - 8B;
*p_51 = t2_36;
p_53 = p_1 - 10B;
*p_53 = t3_41;
p_55 = p_1 - 12B;
*p_55 = t1_31;
j_57 = j_3 + 1;
# Z_5 = PHI <Z_16(0), Z_50(1)>;
# j_3 = PHI <1(0), j_57(1)>;
# p_1 = PHI <&T + 96B(0), p_55(1)>;
<L1>:;
if (j_3 <= 7) goto <L0>; else goto <L2>;
<L2>:;
<L3>:;
return;
}
Notice definition of p_1. We miss the fact that address of T is taken. Fixed
by attached patch (that is simplification of earlier patch solving the same
problem). At the very moment we don't get any problems as we don't promote
arrays, however I am just testing patch to do this.
Bootstrapped/regtested i686-pc-gnu-linux. OK?
Honza
2003-12-19 Jan Hubicka <jh@suse.cz>
* tree-must-alias.c (find_addressable_vars): Deal properly with
nontrivial memory addresses.
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-must-alias.c,v
retrieving revision 1.1.2.16
diff -c -3 -p -r1.1.2.16 tree-must-alias.c
*** tree-must-alias.c 17 Dec 2003 03:36:14 -0000 1.1.2.16
--- tree-must-alias.c 19 Dec 2003 16:57:13 -0000
*************** find_addressable_vars (void)
*** 188,199 ****
{
tree t = PHI_ARG_DEF (phi, i);
if (TREE_CODE (t) != ADDR_EXPR)
continue;
! t = TREE_OPERAND (t, 0);
! if (TREE_CODE (t) != VAR_DECL && TREE_CODE (t) != PARM_DECL)
! continue;
! SET_BIT (addresses_needed, var_ann (t)->uid);
}
}
}
--- 188,200 ----
{
tree t = PHI_ARG_DEF (phi, i);
+ if (TREE_CODE (t) == PLUS_EXPR)
+ t = TREE_OPERAND (t, 0);
if (TREE_CODE (t) != ADDR_EXPR)
continue;
! t = get_base_symbol (TREE_OPERAND (t, 0));
! if (t && (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == PARM_DECL))
! SET_BIT (addresses_needed, var_ann (t)->uid);
}
}
}
More information about the Gcc-patches
mailing list