[PATCH] D36073: [CGP] Extends the scope of optimizeMemoryInst optimization

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 31 00:19:11 PDT 2017


skatkov created this revision.

This is an implementation of PR26223.

Currently optimizeMemoryInst optimization tries to fold address computation
if all possible way to get compute the address are of the form

  baseGV + base + scale * Index + offset

where sale and offset are constants and baseGV, base and Index are exactly
the same instructions if defined.

The patch extends this optimization to allow different bases. In this case
it tries to find/bild a Phi node merging all possible bases and use this Phi node
as a base for sunk address computation.

The main motivation for this scope extension is GCRelocateInst.
If there is a relocation of derived pointer it will be represented as relocation + offset.
Also there will be a Phi node merging address computation for relocated derived pointer
and derived pointer itself. If we have a Phi node merging original base and relocated base
and can fold the address computation of derived pointer then we can potentially reduce
the code size and Phi node for derived pointer. The later can have a positive impact to
register allocator.


https://reviews.llvm.org/D36073

Files:
  lib/CodeGen/CodeGenPrepare.cpp
  test/Transforms/CodeGenPrepare/X86/sink-addrmode-base.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36073.108867.patch
Type: text/x-patch
Size: 25650 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170731/4a0024eb/attachment.bin>


More information about the llvm-commits mailing list