aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-02-22 10:14:00 +0100
committerJakub Jelinek <jakub@redhat.com>2024-02-22 10:14:00 +0100
commit853cbcb7a74ecd95efcba25279b270f0a868d584 (patch)
tree64a46d130a5669cedf7000b9cfd44fe6273c1ade /libcpp
parent00bc8c0998d83fd08c567607f2e052108bfa39c7 (diff)
downloadgcc-853cbcb7a74ecd95efcba25279b270f0a868d584.zip
gcc-853cbcb7a74ecd95efcba25279b270f0a868d584.tar.gz
gcc-853cbcb7a74ecd95efcba25279b270f0a868d584.tar.bz2
bitintlower: Fix .MUL_OVERFLOW overflow checking [PR114038]
Currently, bitint_large_huge::lower_mul_overflow uses cnt 1 only if startlimb == endlimb and in that case doesn't use a loop and handles everything in a special if: unsigned cnt; bool use_loop = false; if (startlimb == endlimb) cnt = 1; else if (startlimb + 1 == endlimb) cnt = 2; else if ((end % limb_prec) == 0) { cnt = 2; use_loop = true; } else { cnt = 3; use_loop = startlimb + 2 < endlimb; } if (cnt == 1) { ... } else The loop handling for the loop exit condition wants to compare if the incremented index is equal to endlimb, but that is correct only if end is not divisible by limb_prec and there will be a straight line check after the loop as well for the most significant limb. The code used endlimb + (cnt == 1) for that, but cnt == 1 is never true here, because cnt is either 2 or 3, so the right check is (cnt == 2). 2024-02-22 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/114038 * gimple-lower-bitint.cc (bitint_large_huge::lower_mul_overflow): Fix loop exit condition if end is divisible by limb_prec. * gcc.dg/torture/bitint-59.c: New test.
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions