[PATCH] D34592: [IR] Implement commutable matchers without using combineOr

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 23 22:03:56 PDT 2017


craig.topper created this revision.

Turns out creating matchers with combineOr isn't very efficient as we have to build matcher objects for both sides of the OR. Those objects aren't free, the trees usually contain several objects that contain a reference to a Value *, ConstantInt *, APInt * or some such thing. The compiler isn't always willing to inline all the matcher code to get rid of these member variables. Thus we end up loads and stores of these variables.

Using combineOR ends up creating two complete copies of the tree and the associated stores. I believe we're also paying for the opcode check twice.

This patch adds a commutable mode to several of the matcher objects as a bool template parameter that can be used to enable  commutable support directly in the match functions of the corresponding objects. This avoids the duplicate object creation and the opcode checks.

This shows about an ~7-8k reduction in the opt binary size on my local build.


https://reviews.llvm.org/D34592

Files:
  include/llvm/IR/PatternMatch.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34592.103829.patch
Type: text/x-patch
Size: 9527 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170624/2dd4be19/attachment.bin>


More information about the llvm-commits mailing list