public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/48510] New: Does not vectorize loops involving casts from floating point to integer types
@ 2011-04-08 7:00 jeremysalwen at gmail dot com
2011-04-08 10:02 ` [Bug target/48510] Does not vectorize loops involving casts from floating point to unsigned " rguenth at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: jeremysalwen at gmail dot com @ 2011-04-08 7:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48510
Summary: Does not vectorize loops involving casts from floating
point to integer types
Product: gcc
Version: 4.5.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jeremysalwen@gmail.com
The following code vectorizes with the command line options:
-march=native -mtune=native -ftree-vectorizer-verbose=12 -O3 -std=c99
-ffast-math -funsafe-math-optimizations -lm main.c
#include <stdio.h>
#include <math.h>
int main() {
double g[1000];
for(int i=0; i<1000; i++) {
g[i]=2*(g[i]);
}
for(int i=0; i<1000; i++) {
printf("%f\n",g[i]);
}
}
but the following code does not with the same options:
#include <stdio.h>
#include <math.h>
int main() {
double g[1000];
for(int i=0; i<1000; i++) {
g[i]=2*((unsigned long)g[i]);
}
for(int i=0; i<1000; i++) {
printf("%f\n",g[i]);
}
}
If I understand correctly, there are SSE instructions for casting doubles to
long integers on the platform I'm on (Intel Atom) which GCC could use. (or
perhaps there could be a benefit to vectorizing other parts of the loop, even
if the cast does not utilize SIMD instructions.)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/48510] Does not vectorize loops involving casts from floating point to unsigned integer types
2011-04-08 7:00 [Bug c/48510] New: Does not vectorize loops involving casts from floating point to integer types jeremysalwen at gmail dot com
@ 2011-04-08 10:02 ` rguenth at gcc dot gnu.org
2011-04-08 17:43 ` [Bug c/48510] " jeremysalwen at gmail dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-08 10:02 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48510
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target| |x86_64-*-*, i?86-*-*
Status|UNCONFIRMED |NEW
Keywords| |missed-optimization
Last reconfirmed| |2011.04.08 10:02:15
Component|c |target
Ever Confirmed|0 |1
Summary|Does not vectorize loops |Does not vectorize loops
|involving casts from |involving casts from
|floating point to integer |floating point to unsigned
|types |integer types
Severity|normal |enhancement
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-08 10:02:15 UTC ---
There are no conversions to unsigned. For scalar code we work around this
by biasing the input/output, but there is no vectorized version for this
available (yet).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/48510] Does not vectorize loops involving casts from floating point to unsigned integer types
2011-04-08 7:00 [Bug c/48510] New: Does not vectorize loops involving casts from floating point to integer types jeremysalwen at gmail dot com
2011-04-08 10:02 ` [Bug target/48510] Does not vectorize loops involving casts from floating point to unsigned " rguenth at gcc dot gnu.org
@ 2011-04-08 17:43 ` jeremysalwen at gmail dot com
2011-04-08 18:38 ` [Bug target/48510] " pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jeremysalwen at gmail dot com @ 2011-04-08 17:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48510
jeremysalwen at gmail dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|target |c
Severity|enhancement |normal
--- Comment #2 from jeremysalwen at gmail dot com 2011-04-08 17:43:25 UTC ---
As you mentioned, unsigned conversions to int and long int both fail to
vectorize. However, signed conversions to long int still fail, while they
succeed for signed conversions to int.
I should note that the computer I ran these last tests on is a Phenom II.
Apologies if I'm mistaken, but I believe the intrinsic
__builtin_ia32_cvttsd2si64
should do the conversion to a signed long on my platform.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/48510] Does not vectorize loops involving casts from floating point to unsigned integer types
2011-04-08 7:00 [Bug c/48510] New: Does not vectorize loops involving casts from floating point to integer types jeremysalwen at gmail dot com
2011-04-08 10:02 ` [Bug target/48510] Does not vectorize loops involving casts from floating point to unsigned " rguenth at gcc dot gnu.org
2011-04-08 17:43 ` [Bug c/48510] " jeremysalwen at gmail dot com
@ 2011-04-08 18:38 ` pinskia at gcc dot gnu.org
2012-07-13 8:42 ` rguenth at gcc dot gnu.org
2012-07-19 10:57 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-04-08 18:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48510
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |target
Severity|normal |enhancement
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/48510] Does not vectorize loops involving casts from floating point to unsigned integer types
2011-04-08 7:00 [Bug c/48510] New: Does not vectorize loops involving casts from floating point to integer types jeremysalwen at gmail dot com
` (2 preceding siblings ...)
2011-04-08 18:38 ` [Bug target/48510] " pinskia at gcc dot gnu.org
@ 2012-07-13 8:42 ` rguenth at gcc dot gnu.org
2012-07-19 10:57 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-13 8:42 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48510
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |53947
--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-13 08:42:23 UTC ---
Link to vectorizer missed-optimization meta-bug.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug target/48510] Does not vectorize loops involving casts from floating point to unsigned integer types
2011-04-08 7:00 [Bug c/48510] New: Does not vectorize loops involving casts from floating point to integer types jeremysalwen at gmail dot com
` (3 preceding siblings ...)
2012-07-13 8:42 ` rguenth at gcc dot gnu.org
@ 2012-07-19 10:57 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-07-19 10:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48510
--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-07-19 10:57:07 UTC ---
We can now vectorize the conversion to unsigned int, it is not possible to
directly convert from double to unsigned long as far as I can see - only
cvttpd2dq exists which is a signed conversion. Biasing the input value
from [0, ULONG_MAX] to [-LONG_MIN, LONG_MAX] is not possible because of
the different truncation behavior for signed/unsigned values.
As a side-note, C specifies that float -> unsigned integer truncation
only has defined behavior for inputs in the range (-1, Utype_MAX+1).
ICC seems to use some clever range-dependent operations, finally mixing
three cases together with bitwise operations.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-07-19 10:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-08 7:00 [Bug c/48510] New: Does not vectorize loops involving casts from floating point to integer types jeremysalwen at gmail dot com
2011-04-08 10:02 ` [Bug target/48510] Does not vectorize loops involving casts from floating point to unsigned " rguenth at gcc dot gnu.org
2011-04-08 17:43 ` [Bug c/48510] " jeremysalwen at gmail dot com
2011-04-08 18:38 ` [Bug target/48510] " pinskia at gcc dot gnu.org
2012-07-13 8:42 ` rguenth at gcc dot gnu.org
2012-07-19 10:57 ` 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).