On Wed, 5 Dec 2018 at 15:34, Roger Cuypers <rcuyp...@arcor.de> wrote: > > Greetings, > > I’m trying to have the Aarch64 gcc optimize a single function using the O3 > optimization in this manner: > > void __attribute__ ((optimize ("-O3", "-ftree-vectorize" ))) > However, when examining the assembler code, there is no trace of any > optimization beyond the project default. > The only way to successfully enforce the optimization is using -O3 in the gcc > command line. Then the compiler produces ARM neon instructions. > > Do you know any issues regarding function level optimizations and the Aarch64 > gcc? >
Hello, Which version of GCC are you using? I've just tried with gcc-arm-8.2, with this sample code: ============================================== #define SIZE 100 int a[SIZE]; int b[SIZE]; //int myfunc() __attribute__ ((optimize ("-O3", "-ftree-vectorize" ))); int myfunc() { int i; int s=0; for(i=0; i<SIZE; i++) s+=a[i]+b[i]; return s; } ============================================== Compiled at -O2, the loop contains: ldr w2, [x5, x1] ldr w3, [x4, x1] add x1, x1, 4 cmp x1, 400 add w2, w2, w3 add w0, w0, w2 If I un-comment the attribute line, I get: ldr q0, [x2, x0] ldr q2, [x1, x0] add x0, x0, 16 cmp x0, 400 add v0.4s, v0.4s, v2.4s add v1.4s, v1.4s, v0.4s In addition, -ftree-vectorize is not needed, it's implied by -O3. Thanks, Christophe > Regards > _______________________________________________ > linaro-toolchain mailing list > linaro-toolchain@lists.linaro.org > https://lists.linaro.org/mailman/listinfo/linaro-toolchain _______________________________________________ linaro-toolchain mailing list linaro-toolchain@lists.linaro.org https://lists.linaro.org/mailman/listinfo/linaro-toolchain