[PATCH] D105069: [GlobalISel] Add re-association combine for G_PTR_ADD to allow better addressing mode usage.

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 28 16:54:58 PDT 2021


aemerson created this revision.
aemerson added reviewers: arsenm, paquette.
aemerson added a project: LLVM.
Herald added subscribers: hiraditya, kristof.beyls, rovka.
aemerson requested review of this revision.
Herald added a subscriber: wdng.

We're trying to match a few pointer computation patterns here for re-association opportunities.

1. Isolating a constant operand to be on the RHS, e.g.:

`G_PTR_ADD(BASE, G_ADD(X, C)) -> G_PTR_ADD(G_PTR_ADD(BASE, X), C)`

2. Folding two constants in each sub-tree as long as such folding doesn't break a legal addressing mode.

`G_PTR_ADD(G_PTR_ADD(BASE, C1), C2) -> G_PTR_ADD(BASE, C1+C2)`

AArch64 code size improvements on CTMark with -Os:

  Program              before  after   diff
  pairlocalalign      251048  251044 -0.0%
  consumer-typeset    421820  421812 -0.0%
  kc                  431348  431320 -0.0%
  SPASS               413404  413300 -0.0%
  clamscan            384396  384220 -0.0%
  tramp3d-v4          370640  370412 -0.1%
  lencod              432096  431772 -0.1%
  bullet              479400  478796 -0.1%
  sqlite3             288504  288072 -0.1%
  7zip-benchmark      573796  570768 -0.5%
  Geomean difference                 -0.1%


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105069

Files:
  llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
  llvm/include/llvm/Target/GlobalISel/Combine.td
  llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/combine-ptradd-reassociation.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105069.355071.patch
Type: text/x-patch
Size: 15484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210628/5a803e02/attachment.bin>


More information about the llvm-commits mailing list