Currently, inline cost model considers a binary operator as free only if both its operands are constants. Some simple cases are missing such as a + 0, a - a, etc. This patch modifies visitBinaryOperator() to call SimplifyBinOp() without going through simplifyInstruction() to get rid of the constant restriction. Thus, visitAnd() and visitOr() are not needed.
Here is the impact on code size and performance (spec20xx)
Benchmark | Code Size (%) | Perf (%) |
(+ is bigger) | (+ is faster) | |
spec2000/gcc | 0.02 | 2.26 |
spec2006/gcc | 0.04 | 2.18 |
spec2017/imagick | 0.03 | 1.02 |
spec2006/perlbench | 0.00 | 0.60 |
spec2000/crafty | 0.43 | 0.58 |
spec2017/parest | 0.01 | 0.16 |
spec2017/gcc | -0.01 | 0.14 |
spec2006/xalancbmk | 0.00 | 0.12 |
spec2006/dealII | 0.04 | 0.10 |
spec2017/blender | 0.00 | -0.04 |
spec2017/povray | -1.46 | -0.12 |
spec2017/xalancbmk | 0.61 | -0.14 |
spec2006/povray | -1.35 | -0.15 |