[llvm] r276136 - Use ValueOffsetPair to enhance value reuse during SCEV expansion.

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 16:34:03 PDT 2016


On Wed, Jul 20, 2016 at 9:40 AM, Wei Mi via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: wmi
> Date: Wed Jul 20 11:40:33 2016
> New Revision: 276136
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276136&view=rev
> Log:
> Use ValueOffsetPair to enhance value reuse during SCEV expansion.
>
> In D12090, the ExprValueMap was added to reuse existing value during SCEV expansion.
> However, const folding and sext/zext distribution can make the reuse still difficult.
>
> A simplified case is: suppose we know S1 expands to V1 in ExprValueMap, and
>   S1 = S2 + C_a
>   S3 = S2 + C_b
> where C_a and C_b are different SCEVConstants. Then we'd like to expand S3 as
> V1 - C_a + C_b instead of expanding S2 literally. It is helpful when S2 is a
> complex SCEV expr and S2 has no entry in ExprValueMap, which is usually caused
> by the fact that S3 is generated from S1 after const folding.
>
> In order to do that, we represent ExprValueMap as a mapping from SCEV to
> ValueOffsetPair. We will save both S1->{V1, 0} and S2->{V1, C_a} into the
> ExprValueMap when we create SCEV for V1. When S3 is expanded, it will first
> expand S2 to V1 - C_a because of S2->{V1, C_a} in the map, then expand S3 to
> V1 - C_a + C_b.
>
> Differential Revision: https://reviews.llvm.org/D21313

I've reverted this in r276822 as it caused us to miscompile Clang when
self-hosting on Windows (PR28705).


More information about the llvm-commits mailing list