llvm-6502/test/Analysis
Andrew Trick a5c5bc9948 SCEV should use NSW to get trip count for positive nonunit stride loops.
SCEV currently fails to compute loop counts for nonunit stride
loops. This comes up frequently. It prevents loop optimization and
forces vectorization to insert extra loop checks.

For example:
void foo(int n, int *x) {
 for (int i = 0; i < n; i += 3) {
   x[i] = i;
   x[i+1] = i+1;
   x[i+2] = i+2;
 }
}

We need to properly handle the case in which limit > INT_MAX-stride. In
the above case: n > INT_MAX-3. In this case the loop counter will step
beyond the limit and overflow at the same time. However, knowing that
signed integer overlow in undefined, we can assume the loop test
behavior is arbitrary after overflow. This obeys both C undefined
behavior rules, and the more strict LLVM poison value rules.

I'm finally fixing this in response to Hal Finkel's persistence.
The most probable reason that we never optimized this before is that
we were being careful to handle case where the developer expected a
side-effect free infinite loop relying on overflow:

for (int i = 0; i < n; i += s) {
  ++j;
}
return j;

If INT_MAX+1 is a multiple of s and n > INT_MAX-s, then we might
expect an infinite loop. However there are plenty of ways to achieve
this effect without relying on undefined behavior of signed overflow.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193015 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-18 23:43:53 +00:00
..
BasicAA Use CHECK-LABEL 2013-09-30 23:31:55 +00:00
BlockFrequencyInfo [tests] Cleanup initialization of test suffixes. 2013-08-16 00:37:11 +00:00
BranchProbabilityInfo [tests] Cleanup initialization of test suffixes. 2013-08-16 00:37:11 +00:00
CallGraph [tests] Cleanup initialization of test suffixes. 2013-08-16 00:37:11 +00:00
CostModel X86 horizontal vector reduction cost model 2013-09-19 17:48:48 +00:00
DependenceAnalysis [tests] Cleanup initialization of test suffixes. 2013-08-16 00:37:11 +00:00
Dominators [tests] Cleanup initialization of test suffixes. 2013-08-16 00:37:11 +00:00
GlobalsModRef [tests] Cleanup initialization of test suffixes. 2013-08-16 00:37:11 +00:00
Lint Fix lint assert on integer vector division 2013-08-26 23:29:33 +00:00
LoopInfo FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
MemoryDependenceAnalysis [tests] Cleanup initialization of test suffixes. 2013-08-16 00:37:11 +00:00
PostDominators FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
RegionInfo [tests] Cleanup initialization of test suffixes. 2013-08-16 00:37:11 +00:00
ScalarEvolution SCEV should use NSW to get trip count for positive nonunit stride loops. 2013-10-18 23:43:53 +00:00
TypeBasedAliasAnalysis TBAA: handle scalar TBAA format and struct-path aware TBAA format. 2013-09-27 18:34:27 +00:00