[CVP] Fold return values if possible
authorPhilip Reames <listmail@philipreames.com>
Wed, 4 Nov 2015 01:43:54 +0000 (01:43 +0000)
committerPhilip Reames <listmail@philipreames.com>
Wed, 4 Nov 2015 01:43:54 +0000 (01:43 +0000)
commite93434193fd26c946d841d6a52b03086b0c57499
tree51d3a96b9ec891fcbdfcab35d7ec65b7e0959e0a
parent7e6636cb71f619b2ebf8b81c688933edf56beebf
[CVP] Fold return values if possible

In my previous change to CVP (251606), I made CVP much more aggressive about trying to constant fold comparisons. This patch is a reversal in direction. Rather than being agressive about every compare, we restore the non-block local restriction for most, and then try hard for compares feeding returns.

The motivation for this is two fold:
 * The more I thought about it, the less comfortable I got with the possible compile time impact of the other approach. There have been no reported issues, but after talking to a couple of folks, I've come to the conclusion the time probably isn't justified.
 * It turns out we need to know the context to leverage the full power of LVI. In particular, asking about something at the end of it's block (the use of a compare in a return) will frequently get more precise results than something in the middle of a block. This is an implementation detail, but it's also hard to get around since mid-block queries have to reason about possible throwing instructions and don't get to use most of LVI's block focused infrastructure. This will become particular important when combined with http://reviews.llvm.org/D14263.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252032 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
test/Transforms/CorrelatedValuePropagation/select.ll