1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00
llvm-mirror/lib
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
..
Analysis [SCEV] No-wrap flags are not propagated when folding "{S,+,X}+T ==> {S+T,+,X}" 2016-05-25 13:01:33 +00:00
AsmParser Refactor duplicated code. NFC. 2016-05-12 12:37:52 +00:00
Bitcode Add FIXMEs to all derived classes of std::error_category. 2016-05-24 20:13:46 +00:00
CodeGen ScheduleDAGInstrs: Fix memory corruption 2016-05-25 01:18:00 +00:00
DebugInfo [llvm-pdbdump] Decipher the remaining PDB streams. 2016-05-25 05:49:48 +00:00
ExecutionEngine Add FIXMEs to all derived classes of std::error_category. 2016-05-24 20:13:46 +00:00
Fuzzer [libFuzzer] print stats if we crash on empty input 2016-05-25 00:15:36 +00:00
IR [X86][SSE] Replace (V)CVTDQ2PD(Y) and (V)CVTPS2PD(Y) lossless conversion intrinsics with generic IR 2016-05-25 08:59:18 +00:00
IRReader
LibDriver
LineEditor
Linker Return a StringRef from getSection. 2016-05-11 18:21:59 +00:00
LTO [ThinLTO] Handle empty exports list for module. 2016-05-24 19:12:48 +00:00
MC Revert r270569 (teach llvm-mc to generate compressed debug sections in zlib 2016-05-25 00:14:12 +00:00
Object Add FIXMEs to all derived classes of std::error_category. 2016-05-24 20:13:46 +00:00
ObjectYAML [MachOYAML] Removing duplicated field from LC_UUID YAML 2016-05-20 18:36:52 +00:00
Option
Passes [PM] Port BDCE to the new pass manager. 2016-05-25 01:57:04 +00:00
ProfileData Add FIXMEs to all derived classes of std::error_category. 2016-05-24 20:13:46 +00:00
Support [AArch64] Adding a TargetParser for AArch64 2016-05-25 12:02:33 +00:00
TableGen
Target [X86][SSE] Replace (V)CVTDQ2PD(Y) and (V)CVTPS2PD(Y) lossless conversion intrinsics with generic IR 2016-05-25 08:59:18 +00:00
Transforms [X86][SSE] Replace (V)CVTDQ2PD(Y) and (V)CVTPS2PD(Y) lossless conversion intrinsics with generic IR 2016-05-25 08:59:18 +00:00
CMakeLists.txt
LLVMBuild.txt