summaryrefslogtreecommitdiffstats
path: root/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
diff options
context:
space:
mode:
authorOleg Ranevskyy <oranevskyy@accesssoftek.com>2016-05-25 13:01:33 +0000
committerOleg Ranevskyy <oranevskyy@accesssoftek.com>2016-05-25 13:01:33 +0000
commiteb4eccae5c14cb6730b9c3a4a0f9069427f3e459 (patch)
tree2f38213a6c87e2e2727f7607612fbe08eb846ebc /llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
parent2fd1654278ef9cf2af0fa342a70f8e9a4eb7ddb0 (diff)
downloadbcm5719-llvm-eb4eccae5c14cb6730b9c3a4a0f9069427f3e459.tar.gz
bcm5719-llvm-eb4eccae5c14cb6730b9c3a4a0f9069427f3e459.zip
[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
Diffstat (limited to 'llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll')
-rw-r--r--llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll b/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
index 8944d2b1a6b..a9d55f1b3db 100644
--- a/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
+++ b/llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
@@ -420,7 +420,7 @@ loop:
%j = add nsw i32 %i, 1
; CHECK: %index32 =
-; CHECK: --> {(1 + %offset),+,1}<nsw>
+; CHECK: --> {(1 + %offset)<nsw>,+,1}<nsw>
%index32 = add nsw i32 %j, %offset
%ptr = getelementptr inbounds float, float* %input, i32 %index32
@@ -562,7 +562,7 @@ loop:
%i = phi i32 [ %nexti, %loop ], [ %start, %entry ]
; CHECK: %index32 =
-; CHECK: --> {((-1 * %halfsub)<nsw> + %start),+,1}<nsw>
+; CHECK: --> {((-1 * %halfsub)<nsw> + %start)<nsw>,+,1}<nsw>
%index32 = sub nsw i32 %i, %halfsub
%index64 = sext i32 %index32 to i64
@@ -621,7 +621,7 @@ loop:
%j = add nsw i32 %i, 1
; CHECK: %index32 =
-; CHECK: --> {(1 + (-1 * %offset)),+,1}<nsw>
+; CHECK: --> {(1 + (-1 * %offset))<nsw>,+,1}<nsw>
%index32 = sub nsw i32 %j, %offset
%ptr = getelementptr inbounds float, float* %input, i32 %index32
OpenPOWER on IntegriCloud