---
title: 选项 -fifcvt-allow-complicated-cmps
description: "增强if-conversion（条件转换）优化，通过使用更多寄存器减少冲突。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengdevkithistory/hgcc/hist-hgcc/kunpenghgcc_06_0039.html
sourcePath: /source/zh/kunpengdevkithistory/hgcc/hist-hgcc/kunpenghgcc_06_0039.html
indexId: 1b0131c72258fe388cb970f01be76240f4fa47e988cab4cb2a74be92afbf062871
---
# 选项 -fifcvt-allow-complicated-cmps

#### 说明

增强if-conversion（条件转换）优化，通过使用更多寄存器减少冲突。


#### 使用说明

本优化是 RTL优化if-conversion的一部分，使用如下编译选项控制优化启用。

- -param=ifcvt-allow-register-renaming=[0,1,2]默认为0，数字用于控制优化范围。

注：此优化依赖-O2优化等级，并建议与--param=max-rtl-if-conversion-unpredictable-cost=48、--param=max-rtl-if-conversion-predictable-cost=48共同使用。


#### 结果

测试用例如下：

```
typedef unsigned int uint16_t;

uint16_t
foo (uint16_t x, uint16_t y, uint16_t z, uint16_t a,
     uint16_t b, uint16_t c, uint16_t d)
{
    int i = 1;
    int j = 1;
    if (a > b)
    {
        j = x;
        if (b > c)
	    i = y;
        else
	    i = z;
    }
    else
    {
        j = y;
        if (c > d)
	    i = z;
    }
    return i * j;
}
```

测试命令：

```
gcc -O2 -fifcvt-allow-complicated-cmps --param max-rtl-if-conversion-unpredictable-cost=100 --param max-rtl-if-conversion-predictable-cost=100 --param=ifcvt-allow-register-renaming=2 -S test.c -o test.s
```

图1 选项未打开

图2 选项已经打开

启用该选项后，生成的汇编代码消除了分支跳转，并利用更多寄存器以减少冲突。
