public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/110362] New: Range information on lower bytes of __uint128_t
@ 2023-06-22 12:02 antoshkka at gmail dot com
2023-06-22 12:58 ` [Bug rtl-optimization/110362] " rguenth at gcc dot gnu.org
2023-07-06 12:37 ` [Bug tree-optimization/110362] " roger at nextmovesoftware dot com
0 siblings, 2 replies; 3+ messages in thread
From: antoshkka at gmail dot com @ 2023-06-22 12:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110362
Bug ID: 110362
Summary: Range information on lower bytes of __uint128_t
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: antoshkka at gmail dot com
Target Milestone: ---
Consider the following example:
int test (__uint128_t a, __uint128_t b) {
__uint128_t __a = b | (a << 32);
return __a & 0xffffffff;
}
At the moment GCC-14 with -O2 generates the following assembly:
test(unsigned __int128, unsigned __int128):
mov rsi, rdi
mov rax, rdx
sal rsi, 32
or rax, rsi
ret
Which could be simplified to just:
test(unsigned __int128, unsigned __int128):
mov rax, rdx
ret
Godbolt playground: https://godbolt.org/z/K9x5vnhxq
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug rtl-optimization/110362] Range information on lower bytes of __uint128_t
2023-06-22 12:02 [Bug tree-optimization/110362] New: Range information on lower bytes of __uint128_t antoshkka at gmail dot com
@ 2023-06-22 12:58 ` rguenth at gcc dot gnu.org
2023-07-06 12:37 ` [Bug tree-optimization/110362] " roger at nextmovesoftware dot com
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-06-22 12:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110362
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-06-22
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.
Also on the GIMPLE level we have
<bb 2> [local count: 1073741824]:
# RANGE [irange] __int128 unsigned [0, 0][4294967296, +INF] NONZERO
0xffffffffffffffffffffffff00000000
_1 = a_2(D) << 32;
__a_4 = _1 | b_3(D);
_5 = (int) __a_4;
the lowpart cast (int) __a_4 can be simplified to (int) b_3(D) based on
the range info of _1. For example via
(simplify
(convert (ior:c with_possible_nonzero_bits@0 @1))
(if ( ... @0 has all zeros in lower TYPE_PRECSION (type) bits ...)
(convert @1)))
I suppose a variant with b & (a << 32) is already optimized (to zero)?
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/110362] Range information on lower bytes of __uint128_t
2023-06-22 12:02 [Bug tree-optimization/110362] New: Range information on lower bytes of __uint128_t antoshkka at gmail dot com
2023-06-22 12:58 ` [Bug rtl-optimization/110362] " rguenth at gcc dot gnu.org
@ 2023-07-06 12:37 ` roger at nextmovesoftware dot com
1 sibling, 0 replies; 3+ messages in thread
From: roger at nextmovesoftware dot com @ 2023-07-06 12:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110362
Roger Sayle <roger at nextmovesoftware dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|rtl-optimization |tree-optimization
CC| |roger at nextmovesoftware dot com
--- Comment #2 from Roger Sayle <roger at nextmovesoftware dot com> ---
The good news is that this has been fixed in the RTL optimizers/x86 backend,
and GCC-14 currently produces the optimal "mov rax, rdx". However, I agree
with Richard Biener that could/should also be fixed (earlier) at the
tree-level.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-06 12:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-22 12:02 [Bug tree-optimization/110362] New: Range information on lower bytes of __uint128_t antoshkka at gmail dot com
2023-06-22 12:58 ` [Bug rtl-optimization/110362] " rguenth at gcc dot gnu.org
2023-07-06 12:37 ` [Bug tree-optimization/110362] " roger at nextmovesoftware dot com
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).