Rate This Document
Findability
Accuracy
Completeness
Readability

-fif-split

Description

By splitting the if statement blocks with complex conditions, the ability to propagate constants between programs can be enhanced.

Usage

Enable the -O3 optimization level and add the compilation option -fif-split.

Result

The test case is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
static __attribute__((noinline)) int foo (int b)
{
    int res = 1;
    for (int i = 0; i < b; i++) {
        res*=3;
    }
    return res;
}

int main(int argc, char** argv){
    int b = argc;
    int res = 0;
    if (b == 5 || b == 52)
        res = foo(b);
    return res;
}

Test command:

1
gcc -O3 -fif-split test.c -S -o test.s
Figure 1 Option disabled
Figure 2 Option enabled

After the option is enabled, the if (b == 5 || b == 52) statement in the main function is split into two independent conditions, with a jump instruction inserted into each.