On 11/02/2017 05:48 AM, Richard Biener wrote: > > There were elaborate transforms of ptr + CST to ptr->a.b.c[3] in the > past. We have ripped out _most_ of them because of bad interaction > with dependence analysis and _b_o_s warnings. > > But for example PRE might still end up propagating > > _1 = &ptr->a.b.c; > _2 = (*_1)[i_3]; > > as > > _2 = ptr->a.b.c[i_3]; > > But it's not so much GCC building up GIMPLE expressions that would > cause false positives but "valid" C code and "invalid" C code > represented exactly the same in GCC. Let's say I think this is a key point.
> >> Or, if that's not it, what exactly is your concern with this >> enhancement? If it's that it's implemented in forwprop, what >> would be a better place, e.g., earlier in the optimization >> phase? If it's something something else, I'd appreciate it >> if you could explain what. > > For one implementing this in forwprop looks like a move in the > wrong direction. I'd like to have separate warning passes or > at most amend warnings from optimization passes, not add new ones. I tend to agree. That's one of the reasons why I pushed Aldy away from doing this kind of stuff within VRP. What I envision is a pass which does a dominator walk through the blocks. It gathers context sensitive range information as it does the walk. As we encounter array references, we try to check them against the current range information. We could also try to warn about certain pointer computations, though we have to be more careful with those. Though I certainly still worry that the false positive cases which led Aldy, Andrew and myself to look at path sensitive ranges arent' resolved and will limit the utility of doing more array range checking. Jeff