[cfe-dev] Restrict for values that are not parameters
Mark Schimmel
Mark.Schimmel at synopsys.com
Fri Mar 6 12:14:01 PST 2015
I cannot get Clang to add noalias via a cast operation. This code does not produce any warnings, and I believe it's legal, but the restrict qualifier is lost. Am I incorrect about this code being legal? Any idea why the qualifier is stripped? (It is a contrived example. You could imagine address checking and two separate loops.)
#define NOALIAS __restrict
//#define NOALIAS __attribute__((noalias))
void move(
int* velocity_x, int* velocity_y, int* velocity_z,
int* position_x,int* position_y,int* position_z,
int* acceleration_x, int* acceleration_y, int* acceleration_z,
int time_step,
int count,
int stride )
{
{
int* NOALIAS r_acceleration_x = (int* NOALIAS)acceleration_x;
int* NOALIAS r_velocity_x = (int* NOALIAS)velocity_x;
int* NOALIAS r_position_x = (int* NOALIAS)position_x;
int* NOALIAS r_acceleration_y = (int* NOALIAS)acceleration_y;
int* NOALIAS r_velocity_y = (int* NOALIAS)velocity_y;
int* NOALIAS r_position_y = (int* NOALIAS)position_y;
int* NOALIAS r_acceleration_z = (int* NOALIAS)acceleration_z;
int* NOALIAS r_velocity_z = (int* NOALIAS)velocity_z;
int* NOALIAS r_position_z = (int* NOALIAS)position_z;
for (int i=0;i<count*stride;i+=stride)
{
r_velocity_x[i] += r_acceleration_x[i] * time_step;
r_velocity_y[i] += r_acceleration_y[i] * time_step;
r_velocity_z[i] += r_acceleration_z[i] * time_step;
r_position_x[i] += r_velocity_x[i] * time_step;
r_position_y[i] += r_velocity_y[i] * time_step;
r_position_z[i] += r_velocity_z[i] * time_step;
}
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150306/b3c07ce8/attachment.html>
More information about the cfe-dev
mailing list