[llvm-commits] [llvm] r142731 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/load.ll
David Blaikie
dblaikie at gmail.com
Mon Oct 24 11:14:59 PDT 2011
> Make SCEV's brute force analysis stronger in two ways. Firstly, we should be
> able to constant fold load instructions where the argument is a constant.
> Second, we should be able to watch multiple PHI nodes through the loop; this
> patch only supports PHIs in loop headers, more can be done here.
>
> With this patch, we now constant evaluate:
> static const int arr[] = {1, 2, 3, 4, 5};
> int test() {
> int sum = 0;
> for (int i = 0; i < 5; ++i) sum += arr[i];
> return sum;
> }
[I'll test this myself this evening, but I thought this might be worth
asking/discussing]
What happens if you invoke UB in this code by, say, iterating past the
end of the array? Does SCEV act on this in any way, such as replacing
the whole block with unreachable? Would it be possible to produce a
diagnostic of some kind? (I realize once LLVM's doing codegen it's a
bit late for front ends, but I don't know if there are any hooks for
such functionality)
- David
More information about the llvm-commits
mailing list