Here is another libmvec question.  While testing on x86 I could easily make
a loop with calls to sin, cos, log, exp, or pow and see them vectorized when
I compile with -Ofast.  But if I try making a loop with sincos, it does not
get vectorized.  Is that to be expected?

I compiled:

#define _GNU_SOURCE
#include <math.h>
#define SIZE 10000
double x[SIZE], y[SIZE], z[SIZE];
void doit(void) { for (int i = 0; i < SIZE; i++) sincos(x[i],&(y[i]),&(z[i])); }

I see the 'simd' attribute on sincos but I do not get any calls to
_ZGVcN4vvv_sincos, only to sincos.  When I look at the tree dump
files I see a call to __builtin_cexpi and not to sincos or __builtin_sincos,
is that confusing the vectorizer?  When expanded into rtl the call to sincos
does show up, but it never shows up in the tree dumps.

I also tried this program:

#define _GNU_SOURCE
#include <math.h>
#define SIZE 10000
double x[SIZE], y[SIZE];
void doit(void) { for (int i = 0; i < SIZE; i++) x[i] = sin(y[i]) + cos(y[i]); }

Which generated a sincos call, but also did not vectorize it.

Is there any way to get GCC to vectorize a loop with sincos in it?

Steve Ellcey
sell...@cavium.com

Reply via email to