[PATCH] D41494: [InlineCost] Find more free binary operations

Haicheng Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 21 08:04:46 PST 2017


haicheng created this revision.
haicheng added reviewers: chandlerc, eraman, mcrosier, junbuml.
Herald added a subscriber: javed.absar.

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         |


Repository:
  rL LLVM

https://reviews.llvm.org/D41494

Files:
  lib/Analysis/InlineCost.cpp
  test/Transforms/Inline/AArch64/binop.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41494.127885.patch
Type: text/x-patch
Size: 8423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171221/77be7202/attachment.bin>


More information about the llvm-commits mailing list