Thank you for your response. I am already compiling with the -O3 option and the -std=c99 option in the case of c. I tried fixing the b[0] element but i obtained the same result. This is important for me because I am making scientific simulation software in c/c++ and I need it to be as fast as possible, and when I learned about the aliasing problem I wanted to know how to overcome it, for which I have to understand when does the problem presents and how to solve it. Would you happen to know any example in which the pointer aliasing problem is present and then can be overcame by restricted pointers in a manner that I can test it? Thank you again for your time, Best regards, Carlos Alvarez On Sun, Mar 2, 2008 at 4:38 PM, Segher Boessenkool <segher@xxxxxxxxxxxxxxxxxxx> wrote: > > void vecmult(int n, int * restrict a, int * restrict b, int * restrict > > c) > > { > > int i; > > for (i=0; i<n; ++i) { > > a[i] = b[i] * c[i]; > > } > > } > > > > but the times with or without restrict are the same. Why isn't it > > improving performance, am I doing something wrong? > > Well, no matter what, the program will have to perform n reads of > elements of b[] and c[], and perform n writes to elements of a[]. > > You could try adding -O3 and/or some of the vectorisation options. > > Also, you could test something like > > > void vecmult(int n, int * restrict a, int * restrict b, int * restrict > c) > { > int i; > for (i=0; i<n; ++i) { > a[i] = b[0] * c[i]; > } > } > > which has a much bigger opportunity for optimisation (no need to load > from b[0] more than once, only if there is a restrict on b[]). > > > Segher > >