https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96535

            Bug ID: 96535
           Summary: GCC 10 ignoring function __attribute__ optimize for
                    all x86
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: danielhanchen at gmail dot com
  Target Milestone: ---

Hey GCC team!

In GCC 10.x, it seems like any argument to __attribute__((optimize(...)) is
ignored at the function level. GCC 9.x and previous do not have this issue. [Or
maybe only -funroll-loops is ignored not 100% sure]

Detailed example at: https://gcc.godbolt.org/z/PTK4WE

3 Scenarios

1. [GCC 10.2: -O2 -ffast-math -march=haswell -std=c++2a -fopenmp] +
[__attribute__((optimize("O2","fast-math","unroll-loops")))] DOES NOT unroll.

2. [GCC 10.2: -funroll-loops -O2 -ffast-math -march=haswell -std=c++2a
-fopenmp] + [__attribute__((optimize("O2","fast-math","unroll-loops")))] DOES
unroll.

3. [GCC 9.3:  -O2 -ffast-math -march=haswell -std=c++2a -fopenmp] +
[__attribute__((optimize("O2","fast-math","unroll-loops")))] DOES unroll.

It seems that in GCC 10.x, you have to place -funroll-loops in the compilation
string, and function level __attribute__s are ignored?

PS: Code in godbolt is a matrix multiplication kernel. It multiplies 1 column *
1 row of a matrix.

Reply via email to