1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00
llvm-mirror/test/Analysis/LoopAccessAnalysis
Oleg Ranevskyy 34bf60ca68 [SCEV] No-wrap flags are not propagated when folding "{S,+,X}+T ==> {S+T,+,X}"
Summary:
**Description**

This makes `WidenIV::widenIVUse` (IndVarSimplify.cpp) fail to widen narrow IV uses in some cases. The latter affects IndVarSimplify which may not eliminate narrow IV's when there actually exists such a possibility, thereby producing ineffective code.

When `WidenIV::widenIVUse` gets a NarrowUse such as `{(-2 + %inc.lcssa),+,1}<nsw><%for.body3>`, it first tries to get a wide recurrence for it via the `getWideRecurrence` call.
`getWideRecurrence` returns recurrence like this: `{(sext i32 (-2 + %inc.lcssa) to i64),+,1}<nsw><%for.body3>`.

Then a wide use operation is generated by `cloneIVUser`. The generated wide use is evaluated to `{(-2 + (sext i32 %inc.lcssa to i64))<nsw>,+,1}<nsw><%for.body3>`, which is different from the `getWideRecurrence` result. `cloneIVUser` sees the difference and returns nullptr.

This patch also fixes the broken LLVM tests by adding missing <nsw> entries introduced by the correction.

**Minimal reproducer:**
```
int foo(int a, int b, int c);
int baz();

void bar()
{
   int arr[20];
   int i = 0;

   for (i = 0; i < 4; ++i)
     arr[i] = baz();

   for (; i < 20; ++i)
     arr[i] = foo(arr[i - 4], arr[i - 3], arr[i - 2]);
}
```

**Clang command line:**
```
clang++ -mllvm -debug -S -emit-llvm -O3 --target=aarch64-linux-elf test.cpp -o test.ir
```

**Expected result:**
The ` -mllvm -debug` log shows that all the IV's for the second `for` loop have been eliminated.

Reviewers: sanjoy

Subscribers: atrick, asl, aemerson, mzolotukhin, llvm-commits

Differential Revision: http://reviews.llvm.org/D20058

llvm-svn: 270695
2016-05-25 13:01:33 +00:00
..
backward-dep-different-types.ll [LoopAccesses] Remove unused global variables in tests 2015-04-02 04:42:51 +00:00
forward-loop-carried.ll [LAA] LLE 3/6: Rename InterestingDependence to Dependences, NFC 2015-11-03 21:39:52 +00:00
forward-loop-independent.ll [LAA] LLE 3/6: Rename InterestingDependence to Dependences, NFC 2015-11-03 21:39:52 +00:00
independent-interleaved.ll [LAA] Check independence of strided accesses before forward case 2016-05-19 15:37:19 +00:00
interleave-innermost.ll [Vectorization] Actually return from error case in isStridedPtr 2016-01-08 01:55:13 +00:00
memcheck-for-loop-invariant.ll [LAA] Support memchecks involving loop-invariant addresses 2016-03-24 04:28:47 +00:00
non-wrapping-pointer.ll [LAA] Try to prove non-wrapping of pointers if SCEV cannot 2015-06-26 17:25:43 +00:00
nullptr.ll Fix LoopAccessAnalysis when potentially nullptr check are involved 2015-11-05 05:49:43 +00:00
number-of-memchecks.ll [SCEV] No-wrap flags are not propagated when folding "{S,+,X}+T ==> {S+T,+,X}" 2016-05-25 13:01:33 +00:00
pointer-with-unknown-bounds.ll [LAA] LLE 3/6: Rename InterestingDependence to Dependences, NFC 2015-11-03 21:39:52 +00:00
resort-to-memchecks-only.ll [LAA] LLE 3/6: Rename InterestingDependence to Dependences, NFC 2015-11-03 21:39:52 +00:00
reverse-memcheck-bounds.ll [SCEV] No-wrap flags are not propagated when folding "{S,+,X}+T ==> {S+T,+,X}" 2016-05-25 13:01:33 +00:00
safe-no-checks.ll [LAA] LLE 3/6: Rename InterestingDependence to Dependences, NFC 2015-11-03 21:39:52 +00:00
safe-with-dep-distance.ll [LAA] Include MaxSafeDepDistBytes in the analysis print-out 2016-05-13 22:49:13 +00:00
store-to-invariant-check1.ll [LoopAccesses] Allow analysis to complete in the presence of uniform stores 2015-04-08 17:48:40 +00:00
store-to-invariant-check2.ll [LoopAccesses] Allow analysis to complete in the presence of uniform stores 2015-04-08 17:48:40 +00:00
store-to-invariant-check3.ll [LoopAccesses] Allow analysis to complete in the presence of uniform stores 2015-04-08 17:48:40 +00:00
stride-access-dependence.ll [LAA] LLE 3/6: Rename InterestingDependence to Dependences, NFC 2015-11-03 21:39:52 +00:00
underlying-objects-1.ll [getUnderlyingOjbects] Analyze loop PHIs further to remove false positives 2015-04-23 20:09:20 +00:00
underlying-objects-2.ll [LAA] LLE 3/6: Rename InterestingDependence to Dependences, NFC 2015-11-03 21:39:52 +00:00
unsafe-and-rt-checks.ll [LAA] LLE 3/6: Rename InterestingDependence to Dependences, NFC 2015-11-03 21:39:52 +00:00
wrapping-pointer-versioning.ll [SCEV] Improve the run-time checking of the NoWrap predicate 2016-04-25 09:27:16 +00:00