public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/56711] New: spectaculary bad code generated for __uint128_t
@ 2013-03-24 15:30 felix-gcc at fefe dot de
2013-03-24 17:23 ` [Bug tree-optimization/56711] missed optimization for __uint128_t of (unsigned long long)x != x pinskia at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: felix-gcc at fefe dot de @ 2013-03-24 15:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56711
Bug #: 56711
Summary: spectaculary bad code generated for __uint128_t
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: felix-gcc@fefe.de
Consider this function:
size_t scan_ulong(const char* src,unsigned long int* dest) {
register const char *tmp=src;
register unsigned long int l=0;
register unsigned char c;
while ((c=*tmp-'0')<10) {
__uint128_t x=(__uint128_t)l*10+c;
if ((unsigned long)x != x) break;
l=(unsigned long)x;
++tmp;
}
if (tmp-src) *dest=l;
return tmp-src;
}
I'm compiling this with gcc -Os -c test.c on an amd64-linux box.
The code gcc generates is 92 bytes long, the one from clang only 65. What is
happening here? What are all that code doing that gcc is generating there?
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/56711] missed optimization for __uint128_t of (unsigned long long)x != x
2013-03-24 15:30 [Bug rtl-optimization/56711] New: spectaculary bad code generated for __uint128_t felix-gcc at fefe dot de
@ 2013-03-24 17:23 ` pinskia at gcc dot gnu.org
2021-07-26 21:26 ` pinskia at gcc dot gnu.org
2023-11-10 22:47 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-03-24 17:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56711
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |x86_64-linux-gnu
Status|UNCONFIRMED |NEW
Keywords| |missed-optimization
Last reconfirmed| |2013-03-24
Component|rtl-optimization |tree-optimization
Ever Confirmed|0 |1
Summary|spectaculary bad code |missed optimization for
|generated for __uint128_t |__uint128_t of (unsigned
| |long long)x != x
Severity|normal |enhancement
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-03-24 17:22:57 UTC ---
>The code gcc generates is 92 bytes long, the one from clang only 65.
If you are going to compare GCC to clang with respect of code size then you
should analyze the code at least. It is very obvious what GCC is not doing.
Well looking at the generated code GCC does not optimize:
if ((unsigned long)x != x) break;
Into just:
x>>64 == 0
An another example is:
int f(unsigned a)
{
return (unsigned short)a != a;
}
int g(unsigned a)
{
return a>>16 == 0;
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/56711] missed optimization for __uint128_t of (unsigned long long)x != x
2013-03-24 15:30 [Bug rtl-optimization/56711] New: spectaculary bad code generated for __uint128_t felix-gcc at fefe dot de
2013-03-24 17:23 ` [Bug tree-optimization/56711] missed optimization for __uint128_t of (unsigned long long)x != x pinskia at gcc dot gnu.org
@ 2021-07-26 21:26 ` pinskia at gcc dot gnu.org
2023-11-10 22:47 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-26 21:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56711
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I am going to look into implementing this.
Shouldn't be hard:
_5 = a_2(D) & 18446744069414584320;
_1 = _5 != 0;
Note for aarch64 we want to do the opposite on the RTL level though.
Clang is able to produce the shift for x86_64 but for armv8, these two
functions have different code gen :).
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/56711] missed optimization for __uint128_t of (unsigned long long)x != x
2013-03-24 15:30 [Bug rtl-optimization/56711] New: spectaculary bad code generated for __uint128_t felix-gcc at fefe dot de
2013-03-24 17:23 ` [Bug tree-optimization/56711] missed optimization for __uint128_t of (unsigned long long)x != x pinskia at gcc dot gnu.org
2021-07-26 21:26 ` pinskia at gcc dot gnu.org
@ 2023-11-10 22:47 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-10 22:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56711
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=94589
Resolution|--- |FIXED
Target Milestone|--- |12.0
Status|ASSIGNED |RESOLVED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
f5f183843540 f7854e2faf76
This was fixed already for GCC 12 by:
r12-733-gf5f1838435400b
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-10 22:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-24 15:30 [Bug rtl-optimization/56711] New: spectaculary bad code generated for __uint128_t felix-gcc at fefe dot de
2013-03-24 17:23 ` [Bug tree-optimization/56711] missed optimization for __uint128_t of (unsigned long long)x != x pinskia at gcc dot gnu.org
2021-07-26 21:26 ` pinskia at gcc dot gnu.org
2023-11-10 22:47 ` pinskia 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).