https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121468
--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> --- This is another case of ranges oscillating during iterative calculations due to bitmask inconsistancies. THIs situation is a bit different thn the others. The code which intersects bitmasks is fairly old, and when an intersection is being performed and the bitmasks/values are inconsisent, (ie one or more bits should be undefined after the intersection) it simply gives up and changes the mask to varying. This is causing an oscillation as the edge range is: int [362653880, 2147482839] MASK 0x1 VALUE 0xfffffffe And one iteration it is intersected with int [-INF, +INF] MASK 0x80000001 VALUE 0x7ffffffe which the old code bails on (incorrectly I think) and changes the mask to unknown, which becomes int [362653880, 2147482839] This is later union upon entry to BB6 with int [-INF, +INF] MASK 0x80000001 VALUE 0x7ffffffe, and with no bitmask, the union is VARYING. Next iteration, we intersect value with VARYING, and this time the mask will be retained, and when we UNION the values, we cycle back to varying with a bitmask, or int [-INF, +INF] MASK 0x80000001 VALUE 0x7ffffffe There are actually 2 issues in here. (1) First is the incorrect handling of intersection for "undefined" bits, which is then exacerbated by (2) the second, which is those very large ranges are really only 2 or 4 valid values, but we currently only reduce ranges via bitmasks when there is a trailing 0 in the bitmask. If we do not know the trailing bit, adjusting the range is much more difficult, but we should consider doing it if we know there are only a few valid values. working on a solution
