Open acalvert opened 8 years ago
I'm pretty sure it's already using CP internally, so I'd guess there's something in there that's confusing CP, so it isn't sure that n is actually constant. I'll have to look at that.
Treating the arrays as scalars when the indexes can't be analyzed was intentional. Since we're not doing a value-based dependence analysis—i.e., definitions aren't killed like they are in RD—this should be a reasonable, conservative approximation.
In this piece of code, we get dependences as expected: but here, we get all stars: The difference is that one declared
n
as anint
and the other#define
s it as a constant.The problem seems to occur when parsing the subscript as a linear expression. In the latter example, that parsing fails, so the subscript expression on the VariableAccess comes back null. VariableAccess#isScalarAccess (or whatever it's called) simply returns whether that field is null, so all accesses to E (and probably A and B as well) come back as scalars. Is constant propagation needed?
Implication: This likely means that any truly non-linear subscript expression will come back as a scalar. This may be desired behavior, but I'm not actually sure.