Richard Guenther - [RFH] Restrict support for trees (original) (raw)

This is the mail archive of the gcc@gcc.gnu.orgmailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

The patch below teaches points-to analysis about restrict qualifiers of incoming parameters. It is modeled after the special handling of malloc result type pointers, namely creating fake variables we point to and thus trigger creation of NMTs. Unfortunately it doesn't exactly work, as for the testcase

double foo(double * restrict x, double * restrict y) { double res; res = *y + *(y+1); res += *x + *(x+1); return res; }

we generate the constraints (ok)

RESTRICT.4 = &ANYTHING x = &RESTRICT.4 RESTRICT.5 = &ANYTHING y = &RESTRICT.5 D.1282_3 = y + 64 D.1285_8 = x + 64

just like we do for the malloc case, but end up with an extra TMT that causes

Variable: x, UID 1276, double * restrict, type memory tag: TMT.6, default def: x_6

Variable: y, UID 1277, double * restrict, type memory tag: TMT.6, default def: y_1

Variable: TMT.6, UID 1309, double, is addressable, is global, call clobbered, may aliases: { RESTRICT.5 RESTRICT.4 }

and thus

<bb 0>:

VUSE <RESTRICT.4_14>;

VUSE <RESTRICT.5_15>;

D.1281_2 = *y_1; D.1282_3 = y_1 + 8B;

VUSE <RESTRICT.5_15>;

D.1283_4 = *D.1282_3; res_5 = D.1281_2 + D.1283_4;

VUSE <RESTRICT.4_14>;

VUSE <RESTRICT.5_15>;

D.1284_7 = *x_6; D.1285_8 = x_6 + 8B;

VUSE <RESTRICT.4_14>;

D.1286_9 = *D.1285_8; D.1287_10 = D.1284_7 + D.1286_9; res_11 = res_5 + D.1287_10; D.1288_12 = res_11; return D.1288_12;

note how only the offsetted pointer is disambiguated by restrict, while *x and *y seem to alias because of the TMT?

Any suggestion on why this happens?

Thanks, Richard.

Index: tree-ssa-structalias.c

*** tree-ssa-structalias.c (revision 107545) --- tree-ssa-structalias.c (working copy) *************** intra_create_variable_infos (void) *** 3975,3985 **** lhs.offset = 0; lhs.type = SCALAR; lhs.var = create_variable_info_for (t, alias_get_name (t));

--- 4045,4079 ---- lhs.offset = 0; lhs.type = SCALAR; lhs.var = create_variable_info_for (t, alias_get_name (t));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]