[llvm-dev] TryToShrinkGlobalToBoolean in GlobalOpt.cpp issue
Chris Lattner via llvm-dev
llvm-dev at lists.llvm.org
Tue Aug 30 14:19:17 PDT 2016
On Aug 30, 2016, at 1:01 PM, Ryan Taylor via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
> Given some code:
>
> static int x = 100;
>
> int main() {
> x = 101;
> printf("%d\n", x);
> }
>
> results in:
>
> %0 = load i1
> %1 = select %0, 101, 100
> ...
> ...
>
> 1) What architecture(s) does this benefit?
Probably none of them.
The intent of this (very very old) optimization is to expose more value information to the mid-level optimizer, which enables secondary simplification. If this simplification doesn’t happen, then this is probably almost always a loss.
A better way to handle this is for GlobalOpt.cpp to tag the loads with the “new” range metadata: http://llvm.org/docs/LangRef.html#range-metadata
In addition to this not pessimizing code, this would allow the analysis to be more general: instead of identifying 1 or 2 constants, it could be generalized to N ranges.
-Chris
More information about the llvm-dev
mailing list