On Mon, Dec 19, 2022 at 3:57 PM Andrew MacLeod via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > our use of equivalences on range-on-entry calculations cause an issue > through a PHI node when a back edge is involved. ie > a = VARYING > <...> > bb5 > b = PHI <UNDEFINED(2), a (5)> > bb6 > if (a != 0) > goto bb5 > > since the value of b is undefined on the edge 2->5, we ignore it. The > range of a on the edge 6->5 is ~[0,0] > we calculate the range of b to be ~[0,0]. we also provide an > equivalency between a and b. > > Unfortunately the on-entry code looks at equivalencies, and says, "hey, > a and b are equivalent, so we can use the range of b instead" > > So it now thinks a is ~[0,0] and folds away the condition. > > The problem is that b can be considered equivalent to a, but the > converse is not true, because there is a path (2->5) upon which a is not > equivalent to b. we have no way to represent a one way equivalence at > the moment. This patch avoid using that relation in range-on-entry > calculations. > > Perhaps next release I'll add a specific kind of one way equivalence for > this kind of situation. > > Bootstraps on x86_64-pc-linux-gnu with no regressions. OK?
OK. Note that equivalences across backedges can also result in values from one cycle iteration to be used in another - a SSA def in a SSA cycle can have different values. Richard. > > Andrew