-fifcvt-allow-complicated-cmps
Description
If-conversion is enhanced to use more registers to reduce conflicts.
Usage
This optimization is part of the if-conversion optimization of the register transfer language (RTL). To control its enabling status, use the following option:
-param=ifcvt-allow-register-renaming=[0,1,2]: The default value is 0. The value indicates the optimization range.
Note: This optimization requires the -O2 optimization level and must be used together with --param=max-rtl-if-conversion-unpredictable-cost=48 and --param=max-rtl-if-conversion-predictable-cost=48.
Result
The test case is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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; } |
Test command:
1 | 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 |
Figure 1 Option disabled


Figure 2 Option enabled


When this option is enabled, the generated assembly code eliminates branch jumps and uses more registers to reduce conflicts.
Parent topic: Static Compilation Optimization