how to keep command line options but add more optimization flag to certain function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi:
An easy example:
auto f(double*a,unsigned long const N)
{
  for(auto i(0);i!=N;++i) a[i]+=2*i;
}
and then I use g++ -std=c++1z -O2 -march=native -ftree-vectorize -fopt-info -S to compile the source code. The output show: note loop vectorized. That is good.

After that I want to add more aggressive optimization to such function. So I write:
__attribute__((optimize("unroll-loops"))) auto f(double*a,unsigned long const N)
{
  for(auto i(0);i!=N;++i) a[i]+=2*i;
}

and then I use g++ -std=c++1z -O2 -march=native -ftree-vectorize -fopt-info -S to compile the source code. The output just show: note loop unroll 7 times. And then I check the asm file and find out that gcc just does unroll-loops optimization but ignores tree-vectorize
 in the command line.

I also try to use:
#pragma GCC optimize("unroll-loops")auto f(double*a,unsigned long const N){  for(auto i(0);i!=N;++i) a[i]+=2*i;}
still not working. So I want to ask how to keep command line options but add more optimization flag to certain function.

I use g++-5.2, x86-64 linux and cpu support avx2.







[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux