[InstCombine] Teach instcombine not to create extra PHI nodes when folding GEPs
authorSilviu Baranga <silviu.baranga@arm.com>
Mon, 26 Oct 2015 10:25:05 +0000 (10:25 +0000)
committerSilviu Baranga <silviu.baranga@arm.com>
Mon, 26 Oct 2015 10:25:05 +0000 (10:25 +0000)
commitebacf44320b5aa59efa03cd0ae90935fc4b953fd
tree37f74c961ef5eefb926cdaa19d4c54b5c6f3b8b6
parent82ace96a30933c2ded81521de51774d406aba3b1
[InstCombine] Teach instcombine not to create extra PHI nodes when folding GEPs

Summary:
InstCombine tries to transform GEP(PHI(GEP1, GEP2, ..)) into GEP(GEP(PHI(...))
when possible. However, this may leave the old PHI node around. Even if we
do end up folding the GEPs, having an extra PHI node might not be beneficial.

This change makes the transformation more conservative. We now only do this if
the PHI has only one use, and can therefore be removed after the transformation.

Reviewers: jmolloy, majnemer

Subscribers: mcrosier, mssimpso, llvm-commits

Differential Revision: http://reviews.llvm.org/D13887

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251281 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstructionCombining.cpp
test/Transforms/InstCombine/gepphigep.ll