Page MenuHomePhabricator

[InlineCost] Find more free binary operations
ClosedPublic

Authored by haicheng on Dec 21 2017, 8:04 AM.

Details

Summary

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)

BenchmarkCode Size (%)Perf (%)
(+ is bigger)(+ is faster)
spec2000/gcc0.022.26
spec2006/gcc0.042.18
spec2017/imagick0.031.02
spec2006/perlbench0.000.60
spec2000/crafty0.430.58
spec2017/parest0.010.16
spec2017/gcc-0.010.14
spec2006/xalancbmk0.000.12
spec2006/dealII0.040.10
spec2017/blender0.00-0.04
spec2017/povray-1.46-0.12
spec2017/xalancbmk0.61-0.14
spec2006/povray-1.35-0.15

Diff Detail

Repository
rL LLVM

Event Timeline

haicheng created this revision.Dec 21 2017, 8:04 AM
hfinkel accepted this revision.Dec 21 2017, 9:40 AM
hfinkel added a subscriber: hfinkel.

LGTM

It looks like we could do a similar thing in visitCmpInst too (and visitCallSite, however, we'd also need to fix the FIXME about interface inefficiency in CallAnalyzer::simplifyCallSite first?).

This revision is now accepted and ready to land.Dec 21 2017, 9:40 AM
This revision was automatically updated to reflect the committed changes.