public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/115036] New: division is not shortened based on value range
@ 2024-05-10 15:10 hubicka at gcc dot gnu.org
2024-05-13 9:35 ` [Bug middle-end/115036] " rguenth at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: hubicka at gcc dot gnu.org @ 2024-05-10 15:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115036
Bug ID: 115036
Summary: division is not shortened based on value range
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: hubicka at gcc dot gnu.org
Target Milestone: ---
For
long test(long a, long b)
{
if (a > 65535 || a < 0)
__builtin_unreachable ();
if (b > 65535 || b < 0)
__builtin_unreachable ();
return a/b;
}
we produce
test:
.LFB0:
.cfi_startproc
movq %rdi, %rax
cqto
idivq %rsi
ret
while clang does:
test: # @test
.cfi_startproc
# %bb.0:
movq %rdi, %rax
# kill: def $ax killed $ax killed $rax
xorl %edx, %edx
divw %si
movzwl %ax, %eax
retq
clang also by default adds 32bit divide path even when value range is not known
long test(long a, long b)
{
return a/b;
}
compiles as
test: # @test
.cfi_startproc
# %bb.0:
movq %rdi, %rax
movq %rdi, %rcx
orq %rsi, %rcx
shrq $32, %rcx
je .LBB0_1
# %bb.2:
cqto
idivq %rsi
retq
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug middle-end/115036] division is not shortened based on value range
2024-05-10 15:10 [Bug middle-end/115036] New: division is not shortened based on value range hubicka at gcc dot gnu.org
@ 2024-05-13 9:35 ` rguenth at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-05-13 9:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115036
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
former fold_stmt_using_ranges has code to narrow ops.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-13 9:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-10 15:10 [Bug middle-end/115036] New: division is not shortened based on value range hubicka at gcc dot gnu.org
2024-05-13 9:35 ` [Bug middle-end/115036] " rguenth 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).