diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-29 09:24:12 +0000 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-06-29 09:24:12 +0000 |
| commit | 2d756c4feb69e4fe0ed8556e05bc2ff3c7bc1007 (patch) | |
| tree | 7cb2e3a3960add4dcf4c8b9bec3f85aef1ff658b /llvm/test/Transforms/IndVarSimplify | |
| parent | b72664fd21cc1e25cd8420eb37eae3a701976394 (diff) | |
| download | bcm5719-llvm-2d756c4feb69e4fe0ed8556e05bc2ff3c7bc1007.tar.gz bcm5719-llvm-2d756c4feb69e4fe0ed8556e05bc2ff3c7bc1007.zip | |
[LFTR] Fix post-inc pointer IV with truncated exit count (PR41998)
Fixes https://bugs.llvm.org/show_bug.cgi?id=41998. Usually when we
have a truncated exit count we'll truncate the IV when comparing
against the limit, in which case exit count overflow in post-inc
form doesn't matter. However, for pointer IVs we don't do that, so
we have to be careful about incrementing the IV in the wide type.
I'm fixing this by removing the IVCount variable (which was
ExitCount or ExitCount+1) and replacing it with a UsePostInc flag,
and then moving the actual limit adjustment to the individual cases
(which are: pointer IV where we add to the wide type, integer IV
where we add to the narrow type, and constant integer IV where we
add to the wide type).
Differential Revision: https://reviews.llvm.org/D63686
llvm-svn: 364709
Diffstat (limited to 'llvm/test/Transforms/IndVarSimplify')
| -rw-r--r-- | llvm/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll | 7 | ||||
| -rw-r--r-- | llvm/test/Transforms/IndVarSimplify/lftr-pr41998.ll | 5 |
2 files changed, 8 insertions, 4 deletions
diff --git a/llvm/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll b/llvm/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll index 49b24370673..48c8925b5ad 100644 --- a/llvm/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll +++ b/llvm/test/Transforms/IndVarSimplify/2011-11-01-lftrptr.ll @@ -146,8 +146,11 @@ define i8 @testnullptrint(i8* %buf, i8* %end) nounwind { ; PTR64-NEXT: [[GUARD:%.*]] = icmp ult i32 0, [[CNT]] ; PTR64-NEXT: br i1 [[GUARD]], label [[PREHEADER:%.*]], label [[EXIT:%.*]] ; PTR64: preheader: -; PTR64-NEXT: [[TMP1:%.*]] = zext i32 [[CNT]] to i64 -; PTR64-NEXT: [[LFTR_LIMIT:%.*]] = getelementptr i8, i8* null, i64 [[TMP1]] +; PTR64-NEXT: [[TMP1:%.*]] = add i32 [[EI]], -1 +; PTR64-NEXT: [[TMP2:%.*]] = sub i32 [[TMP1]], [[BI]] +; PTR64-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64 +; PTR64-NEXT: [[TMP4:%.*]] = add nuw nsw i64 [[TMP3]], 1 +; PTR64-NEXT: [[LFTR_LIMIT:%.*]] = getelementptr i8, i8* null, i64 [[TMP4]] ; PTR64-NEXT: br label [[LOOP:%.*]] ; PTR64: loop: ; PTR64-NEXT: [[P_01_US_US:%.*]] = phi i8* [ null, [[PREHEADER]] ], [ [[GEP:%.*]], [[LOOP]] ] diff --git a/llvm/test/Transforms/IndVarSimplify/lftr-pr41998.ll b/llvm/test/Transforms/IndVarSimplify/lftr-pr41998.ll index 1f04a4b56a4..6ec5a2d8d8e 100644 --- a/llvm/test/Transforms/IndVarSimplify/lftr-pr41998.ll +++ b/llvm/test/Transforms/IndVarSimplify/lftr-pr41998.ll @@ -42,9 +42,10 @@ define void @test_ptr(i32 %start) { ; CHECK-LABEL: @test_ptr( ; CHECK-NEXT: entry: ; CHECK-NEXT: [[TMP0:%.*]] = trunc i32 [[START:%.*]] to i3 -; CHECK-NEXT: [[TMP1:%.*]] = sub i3 0, [[TMP0]] +; CHECK-NEXT: [[TMP1:%.*]] = sub i3 -1, [[TMP0]] ; CHECK-NEXT: [[TMP2:%.*]] = zext i3 [[TMP1]] to i64 -; CHECK-NEXT: [[LFTR_LIMIT:%.*]] = getelementptr i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @data, i64 0, i64 0), i64 [[TMP2]] +; CHECK-NEXT: [[TMP3:%.*]] = add nuw nsw i64 [[TMP2]], 1 +; CHECK-NEXT: [[LFTR_LIMIT:%.*]] = getelementptr i8, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @data, i64 0, i64 0), i64 [[TMP3]] ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: ; CHECK-NEXT: [[P:%.*]] = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @data, i64 0, i64 0), [[ENTRY:%.*]] ], [ [[P_INC:%.*]], [[LOOP]] ] |

