On Tue, Oct 7, 2025 at 12:27 AM Andrew MacLeod <[email protected]> wrote: > > This PR demonstrated another case where trying to save a few cycles > bites us in the end. > > As mentioned in the PR, it was causing an infinite loop in rangers' > cache. The cache propagation mechanism expects to converge, but > instead we were experiencing a flip-flop between 2 values. > > Starting with : edge 421->413 :[irange] unsigned int [0, 0][4, 6] > MASK 0x4 VALUE 0x0 > > The [5,6] part of that range is impossible due ot the mask, and should > have been removed. When this value is propagated through a few blocks, > it is eventually transformed into [irange] unsigned int [0, 0][4, 6] > MASK 0x7 VALUE 0x0, which now incorporates those invalid values. > > When this value is fed back in, we again get [irange] unsigned int [0, > 0][4, 6] MASK 0x4 VALUE 0x0 (which should again have been [0,0[4,4] ) > and the algorithm continues to oscillate between these 2 values. > > If those extraneous values had been removed from the range as they are > suppose to be, we would have had edge 421->413 :[irange] unsigned int > [0, 0][4, 4] MASK 0x4 VALUE 0x0 and then iteration converges as it > should and there's no problem. > > This is very similar to > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119712 And its time to > simply eliminate this issue. > > This patch changes the bitmask_intersect () routine to adjust range > bounds to match the bitmask if the bitmask changes at all. > > Performance impact is < 0.5% to VRP and eliminates this particular > problem going forward.. presumably. > > Unfortunately, I could not find a way to create a reduced testcase for > this. However, 121987 turns out to also be this same problem, and it > DOES have a reduced testcase, so I incorporated it as the testcase. > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121468 is related to > bitmasks, but is a different issue. > > Bootstraps on build-x86_64-pc-linux-gnu with no new regressions. > > Pushed. > > Andrew
The new test failed on Linux/x86-64 with -m32: /export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/pr121987.c: In function 'main': /export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/pr121987.c:5:21: warning: unsigned conversion from 'long long int' to 'long unsigned int' changes value from '10000000000' to '1410065408' [-Woverflow] FAIL: gcc.dg/pr121987.c (test for excess errors) Excess errors: /export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.dg/pr121987.c:5:21: warning: unsigned conversion from 'long long int' to 'long unsigned int' changes value from '10000000000' to '1410065408' [-Woverflow] -- H.J.
