---
title: 选项 -fif-split
description: "通过拆分包含复杂条件的 if 语句块，增强程序间常量传播的能力。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengdevkithistory/hgcc/hist-hgcc/kunpenghgcc_06_0064.html
sourcePath: /source/zh/kunpengdevkithistory/hgcc/hist-hgcc/kunpenghgcc_06_0064.html
indexId: 52a57d2e8dc284f2598469bfda7895f013c2c7cf09ad69b44ff513d1e4c78f9871
---
# 选项 -fif-split

#### 说明

通过拆分包含复杂条件的 if 语句块，增强程序间常量传播的能力。


#### 使用方法

需开启 -O3 或以上优化等级，同时增加编译选项 -fif-split。


#### 结果

测试用例如下：

```
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;
}
```

测试命令：

```
gcc -O3 -fif-split test.c -S -o test.s
```

图1 选项未打开

图2 选项已打开

选项打开后，main 函数中的 if (b == 5 || b == 52) 被拆分成两个独立条件，各插入了一条跳转指令。
