Hi,
I'm trying to get more of my code to vectorize, but very few of the loops
do. ICC (sorry for mentioning it, don't mean to offend anyone) manages to
vectorize all of the loops in my code, so it is doable (and succeeding
seems to yield a speed-up of 5-10x!).
Is there a way to help out the vectorizer with pragmas and suchlike, to
resolve possible misperceived vector dependence issues?
Here is an example of a few loops in my code that don't vectorize:
(it's simple curve fitting class, hence the variable names. Code cut down
as far as possible for brevity)
class CurveFit
{
public:
union
{
float Curve[4];
struct
{
float a;
float b;
float c;
float d;
};
};
unsigned int DataC;
float DataV[1024];
void Foo ()
{
static float BestFit[4];
// This should vectorize but doesn't
for (i = 0; i < 4; i++)
Curve[i] += BestFit[i];
// ...
static float CacheX[1024];
// This should vectorize but doesn't
for (x = 0, xx = 0; x < LocalDataC; x++)
CacheX[x] = Parameter * xx++;
// ...
static float Temp;
static float CacheParam[1024];
// This should vectorize but doesn't
for (x = 0; x < LocalDataC; x++)
{
Temp = DataV[x] - CacheParam[x] - Curve[3];
CurrentError += (Temp * Temp);
}
// ...
}
};
Can anyone suggest anything that could be done to help the optimizer to
vectorize the loops above?
Thanks.
Gordan