public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/114038] New: wrong code with __builtin_mul_overflow_p() and _BitInt() at -O0
@ 2024-02-21 17:47 zsojka at seznam dot cz
2024-02-21 19:20 ` [Bug tree-optimization/114038] " jakub at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: zsojka at seznam dot cz @ 2024-02-21 17:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114038
Bug ID: 114038
Summary: wrong code with __builtin_mul_overflow_p() and
_BitInt() at -O0
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zsojka at seznam dot cz
CC: jakub at gcc dot gnu.org
Target Milestone: ---
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Created attachment 57481
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57481&action=edit
reduced testcase
Output:
$ x86_64-pc-linux-gnu-gcc testcase.c
$ ./a.out
Aborted
$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r14-9091-20240220194451-g0a6a5f8656c-checking-yes-rtl-df-extra-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--with-cloog --with-ppl --with-isl --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu
--with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r14-9091-20240220194451-g0a6a5f8656c-checking-yes-rtl-df-extra-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240221 (experimental) (GCC)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/114038] wrong code with __builtin_mul_overflow_p() and _BitInt() at -O0
2024-02-21 17:47 [Bug tree-optimization/114038] New: wrong code with __builtin_mul_overflow_p() and _BitInt() at -O0 zsojka at seznam dot cz
@ 2024-02-21 19:20 ` jakub at gcc dot gnu.org
2024-02-22 9:14 ` cvs-commit at gcc dot gnu.org
2024-02-22 9:16 ` jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-21 19:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114038
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2024-02-21
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 57484
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57484&action=edit
gcc14-pr114038.patch
Untested fix.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/114038] wrong code with __builtin_mul_overflow_p() and _BitInt() at -O0
2024-02-21 17:47 [Bug tree-optimization/114038] New: wrong code with __builtin_mul_overflow_p() and _BitInt() at -O0 zsojka at seznam dot cz
2024-02-21 19:20 ` [Bug tree-optimization/114038] " jakub at gcc dot gnu.org
@ 2024-02-22 9:14 ` cvs-commit at gcc dot gnu.org
2024-02-22 9:16 ` jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-22 9:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114038
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:853cbcb7a74ecd95efcba25279b270f0a868d584
commit r14-9131-g853cbcb7a74ecd95efcba25279b270f0a868d584
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Feb 22 10:14:00 2024 +0100
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/114038] wrong code with __builtin_mul_overflow_p() and _BitInt() at -O0
2024-02-21 17:47 [Bug tree-optimization/114038] New: wrong code with __builtin_mul_overflow_p() and _BitInt() at -O0 zsojka at seznam dot cz
2024-02-21 19:20 ` [Bug tree-optimization/114038] " jakub at gcc dot gnu.org
2024-02-22 9:14 ` cvs-commit at gcc dot gnu.org
@ 2024-02-22 9:16 ` jakub at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2024-02-22 9:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114038
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-02-22 9:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-21 17:47 [Bug tree-optimization/114038] New: wrong code with __builtin_mul_overflow_p() and _BitInt() at -O0 zsojka at seznam dot cz
2024-02-21 19:20 ` [Bug tree-optimization/114038] " jakub at gcc dot gnu.org
2024-02-22 9:14 ` cvs-commit at gcc dot gnu.org
2024-02-22 9:16 ` jakub at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).