我要评分
获取效率
正确性
完整性
易理解

-fipa-reorder-fields

The memory space layout is optimized. Members are rearranged in descending order based on their space occupation in a structure to reduce the padding introduced by boundary alignment, reduce the memory size occupied by the entire structure, and improve the cache hit ratio. For example, change the following structure:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
struct S
{
    double a;
    int b;
    double c;
    double d;
    short e;
    double f;
    double g;
    double h;
    double i;
};

To:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
struct S.reorder
{
    double a;
    double i;
    double c;
    double d;
    double f;
    double g;
    double h;
    int b;
    short e;
}

Usage

Add the following content to the option:

1
-O3 -flto -flto-partition=one -fipa-reorder-fields

The -fipa-reorder-fields option can be enabled only when -O3 -flto -flto-partition=one is enabled at the same time.

Optimization effect: Up to 20% performance improvement is observed on the SPEC CPU 2017 intrate 505.mcf benchmark.