1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00
llvm-mirror/test/Analysis/ScalarEvolution
Andrew Trick 027f71d443 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.

llvm-svn: 193015
2013-10-18 23:43:53 +00:00
..
2007-07-15-NegativeStride.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00
2007-08-06-MisinterpretBranch.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2007-08-06-Unsigned.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2007-09-27-LargeStepping.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2007-11-14-SignedAddRec.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2007-11-18-OrInstruction.ll
2008-02-11-ReversedCondition.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-02-12-SMAXTripCount.ll Filecheckize. 2011-11-29 02:05:23 +00:00
2008-02-15-UMax.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-05-25-NegativeStepToZero.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-06-12-BinomialInt64.ll
2008-07-12-UnneededSelect1.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-07-12-UnneededSelect2.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-07-19-InfiniteLoop.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-07-19-WrappingIV.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-07-29-SGTTripCount.ll -disable-output is no longer needed with -analyze. 2010-01-26 19:25:59 +00:00
2008-07-29-SMinExpr.ll Revert r106304 (105548 and friends), which are the SCEVComplexityCompare 2010-06-18 19:54:20 +00:00
2008-08-04-IVOverflow.ll
2008-08-04-LongAddRec.ll
2008-11-02-QuadraticCrash.ll
2008-11-15-CubicOOM.ll
2008-11-18-LessThanOrEqual.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-11-18-Stride1.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-11-18-Stride2.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-12-08-FiniteSGE.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-12-11-SMaxOverflow.ll
2008-12-14-StrideAndSigned.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2008-12-15-DontUseSDiv.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2009-01-02-SignedNegativeStride.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2009-04-22-TruncCast.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2009-05-09-PointerEdgeCount.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
2009-07-04-GroupConstantsWidthMismatch.ll
2010-09-03-RequiredTransitive.ll Add a check to the test Analysis/ScalarEvolution/2010-09-03-RequiredTransitive.ll 2012-12-30 01:42:34 +00:00
2011-03-09-ExactNoMaxBECount.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2012-12-30 02:33:22 +00:00
2011-04-26-FoldAddRec.ll Add newlines at end of test files, no functionality change 2013-07-13 22:00:58 +00:00
2011-10-04-ConstEvolve.ll Missing test case for r141164. 2011-10-05 06:23:32 +00:00
2012-03-26-LoadConstant.ll TBAA: remove !tbaa from testing cases if not used. 2013-04-29 22:42:01 +00:00
2012-05-18-LoopPredRecurse.ll SCEV: Add MarkPendingLoopPredicates to avoid recursive isImpliedCond. 2012-05-19 00:48:25 +00:00
2012-05-29-MulAddRec.ll Fix broken check lines. 2012-08-17 12:28:26 +00:00
and-xor.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
avoid-infinite-recursion-0.ll
avoid-infinite-recursion-1.ll Remove support for parsing the "type i32" syntax for defining a numbered 2011-06-19 00:03:46 +00:00
avoid-smax-0.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
avoid-smax-1.ll Test scalar evolution directly instead of testing the result of 2012-03-22 17:09:31 +00:00
div-overflow.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
do-loop.ll FileCheck-ize tests. 2013-08-22 00:51:19 +00:00
fold.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2012-12-30 01:28:40 +00:00
how-far-to-zero.ll If the step value is a constant zero, the loop isn't going to terminate. Fixes 2012-06-28 23:44:57 +00:00
load.ll 2>&1 doesn't work here, it just creates an empty file called "&1" 2011-10-27 18:27:45 +00:00
max-trip-count-address-space.ll Teach ScalarEvolution about pointer address spaces 2013-09-10 19:55:24 +00:00
max-trip-count.ll Reapply r140979 with fix! We never did get a testcase, but careful review of the 2011-10-03 07:10:45 +00:00
nsw-offset.ll Revert "SCEV: When expanding a GEP the final addition to the base pointer has NUW but not NSW." 2012-04-17 06:33:57 +00:00
nsw.ll Revert "SCEV: When expanding a GEP the final addition to the base pointer has NUW but not NSW." 2012-04-17 06:33:57 +00:00
pointer-sign-bits.ll
pr3909.ll Remove support for parsing the "type i32" syntax for defining a numbered 2011-06-19 00:03:46 +00:00
scev-aa.ll Convert the uses of '|&' to use '2>&1 |' instead, which works on old 2012-07-02 18:37:59 +00:00
scev-invalid.ll Fix SCEV forgetMemoizedResults should search and destroy backedge exprs. 2013-03-26 03:14:53 +00:00
sext-inreg.ll Convert all tests using TCL-style quoting to use shell-style quoting. 2012-07-02 12:47:22 +00:00
sext-iv-0.ll Propagate SCEV no-wrap flags whenever possible. 2011-03-15 00:37:00 +00:00
sext-iv-1.ll Convert all tests using TCL-style quoting to use shell-style quoting. 2012-07-02 12:47:22 +00:00
sext-iv-2.ll -disable-output is no longer needed with -analyze. 2010-01-26 19:25:59 +00:00
sle.ll ScalarEvolution support for <= and >= loops. 2010-04-24 03:09:42 +00:00
smax.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00
SolveQuadraticEquation.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00
trip-count2.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00
trip-count3.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00
trip-count4.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00
trip-count5.ll Convert all tests using TCL-style quoting to use shell-style quoting. 2012-07-02 12:47:22 +00:00
trip-count6.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00
trip-count7.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00
trip-count8.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00
trip-count9.ll SCEV should use NSW to get trip count for positive nonunit stride loops. 2013-10-18 23:43:53 +00:00
trip-count10.ll Unit test for SCEV fix r182989, PR16130. 2013-05-31 16:42:41 +00:00
trip-count11.ll Restore commits 142790 and 142843 - they weren't breaking the build 2011-10-25 12:28:52 +00:00
trip-count12.ll Don't forget to check FlagNW when determining whether an AddRecExpr will wrap 2011-11-09 07:11:37 +00:00
trip-count.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00
undefined.ll Don't attempt to analyze values which are obviously undef. This fixes some 2010-04-22 01:35:11 +00:00
unreachable-code.ll
unsimplified-loop.ll Generalize ScalarEvolution's PHI analysis to handle loops that don't 2010-04-12 07:49:36 +00:00
xor-and.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00
zext-wrap.ll FileCheckize some of the testcases. 2013-08-05 23:43:18 +00:00