Hi! The intent of the code is to find the largest (or smallest) representable float (or double) smaller (or greater than) or equal to the given integral maximum (or minimum). The code uses volatile vars to avoid excess precision, but was relying on (volatile_var1 = something1 - something2) == volatile_var2 to actually store the subtraction into volatile var and read it from there, making it an optimization barrier. That is not the case, we compare directly the rhs of the assignment expression with volatile_var2, so on excess precision targets it can result in unwanted optimizations.
Fixed by using a comma expression to make sure comparison doesn't know the value to compare. Tested on x86_64-linux and i686-linux with various -march= settings, committed to trunk as obvious. 2026-03-02 Jakub Jelinek <[email protected]> PR tree-optimization/124288 * gcc.dg/torture/vec-cvt-1.c (FLTTEST): Use comma expression to store into {flt,dbl}m{in,ax} and read from it again for comparison. --- gcc/testsuite/gcc.dg/torture/vec-cvt-1.c.jj 2026-03-02 11:21:03.545515970 +0100 +++ gcc/testsuite/gcc.dg/torture/vec-cvt-1.c 2026-03-02 14:12:19.190648679 +0100 @@ -55,22 +55,22 @@ flttointtest##intt (void) \ else \ { \ vf2 = fltmin = min - 1.0f; \ - for (vf = 1.0f; (fltmin = vf2 + vf) == vf2; vf = vf * 2.0f) \ + for (vf = 1.0f; fltmin = vf2 + vf, fltmin == vf2; vf = vf * 2.0f) \ ; \ } \ vf2 = fltmax = max + 1.0f; \ - for (vf = 1.0f; (fltmax = vf2 - vf) == vf2; vf = vf * 2.0f) \ + for (vf = 1.0f; fltmax = vf2 - vf, fltmax == vf2; vf = vf * 2.0f) \ ; \ if (min == 0) \ dblmin = 0.0; \ else \ { \ vd2 = dblmin = min - 1.0; \ - for (vd = 1.0; (dblmin = vd2 + vd) == vd2; vd = vd * 2.0) \ + for (vd = 1.0; dblmin = vd2 + vd, dblmin == vd2; vd = vd * 2.0) \ ; \ } \ vd2 = dblmax = max + 1.0; \ - for (vd = 1.0; (dblmax = vd2 - vd) == vd2; vd = vd * 2.0) \ + for (vd = 1.0; dblmax = vd2 - vd, dblmax == vd2; vd = vd * 2.0) \ ; \ for (i = 0; i < N; i++) \ { \ Jakub
