This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/48510] New: Does not vectorize loops involving casts from floating point to integer types


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.)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]