OSDN Git Service

[CGP] Extends the scope of optimizeMemoryInst optimization
authorSerguei Katkov <serguei.katkov@azul.com>
Sun, 5 Nov 2017 05:50:33 +0000 (05:50 +0000)
committerSerguei Katkov <serguei.katkov@azul.com>
Sun, 5 Nov 2017 05:50:33 +0000 (05:50 +0000)
commit30669bbc4038cf4f9a60c6636895803076e1f8e5
treea0c62d6f8eb4cb78682041d0c628c6ef12ce4620
parentc80a0ef3c0cda8ed483d0291170aefb30fe65381
[CGP] Extends the scope of optimizeMemoryInst optimization

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 scale 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/build a Phi node merging all possible bases and use this Phi node
as a base for sunk address computation. Also it supports Select instruction on
the way.

The main motivation for this scope extension is GCRelocateInst.
If there is a relocation of derived pointer it will be represented as relocation of base + 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.

Reviewers: efriedma, dberlin, mkazantsev, reames, john.brawn
Reviewed By: john.brawn
Subscribers: javed.absar, john.brawn, dneilson, llvm-commits
Differential Revision: https://reviews.llvm.org/D36073

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317429 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CodeGenPrepare.cpp