joverbey / oaccrefac

1 stars 1 forks source link

Dependence analysis confused on constant scalar #51

Open acalvert opened 8 years ago

acalvert commented 8 years ago

In this piece of code, we get dependences as expected: const-scalar-1 but here, we get all stars: const-scalar-2 The difference is that one declared n as an int and the other #defines 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.

joverbey commented 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.