diff options
| author | Philip Reames <listmail@philipreames.com> | 2015-10-15 16:51:00 +0000 |
|---|---|---|
| committer | Philip Reames <listmail@philipreames.com> | 2015-10-15 16:51:00 +0000 |
| commit | a956cc7f085d8284d7c7cfd11fc20477838b2c04 (patch) | |
| tree | e364b29fa862fd07c58ca8b87fbf4f210ad1779d /llvm/test | |
| parent | 5b327712b07225385a6370f6acd245b8690670b0 (diff) | |
| download | bcm5719-llvm-a956cc7f085d8284d7c7cfd11fc20477838b2c04.tar.gz bcm5719-llvm-a956cc7f085d8284d7c7cfd11fc20477838b2c04.zip | |
Revert 250343 and 250344
Turns out this approach is buggy. In discussion about follow on work, Sanjoy pointed out that we could be subject to circular logic problems.
Consider:
if (i u< L) leave()
if ((i + 1) u< L) leave()
print(a[i] + a[i+1])
If we know that L is less than UINT_MAX, we could possible prove (in a control dependent way) that i + 1 does not overflow. This gives us:
if (i u< L) leave()
if ((i +nuw 1) u< L) leave()
print(a[i] + a[i+1])
If we now do the transform this patch proposed, we end up with:
if ((i +nuw 1) u< L) leave_appropriately()
print(a[i] + a[i+1])
That would be a miscompile when i==-1. The problem here is that the control dependent nuw bits got used to prove something about the first condition. That's obviously invalid.
This won't happen today, but since I plan to enhance LVI/CVP with exactly that transform at some point in the not too distant future...
llvm-svn: 250430
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/SimplifyCFG/fast-fallthrough.ll | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/fast-fallthrough.ll b/llvm/test/Transforms/SimplifyCFG/fast-fallthrough.ll deleted file mode 100644 index 7c5dbe2b0ad..00000000000 --- a/llvm/test/Transforms/SimplifyCFG/fast-fallthrough.ll +++ /dev/null @@ -1,86 +0,0 @@ -; RUN: opt -S %s -simplifycfg | FileCheck %s - -define void @test(i32 %length.i, i32 %i) { -; CHECK-LABEL: @test - %iplus1 = add nsw i32 %i, 1 - %var29 = icmp slt i32 %i, %length.i - %var30 = icmp slt i32 %iplus1, %length.i -; CHECK: br i1 %var30, label %in_bounds, label %next - br i1 %var29, label %next, label %out_of_bounds, !prof !{!"branch_weights", i32 1000, i32 0} - -next: -; CHECK-LABEL: next: -; CHECK: br i1 %var29, label %out_of_bounds2, label %out_of_bounds - br i1 %var30, label %in_bounds, label %out_of_bounds2, !prof !{!"branch_weights", i32 1000, i32 0} - -in_bounds: - ret void - -out_of_bounds: - call void @foo(i64 0) - unreachable - -out_of_bounds2: - call void @foo(i64 1) - unreachable -} - -define void @test2(i32 %length.i, i32 %i) { -; CHECK-LABEL: @test2 - %var29 = icmp slt i32 %i, %length.i -; CHECK: br i1 %var30, label %in_bounds, label %next - br i1 %var29, label %next, label %out_of_bounds, !prof !{!"branch_weights", i32 1000, i32 0} - -next: -; CHECK-LABEL: next: -; CHECK: br i1 %var29, label %out_of_bounds2, label %out_of_bounds - %iplus1 = add nsw i32 %i, 1 - %var30 = icmp slt i32 %iplus1, %length.i - br i1 %var30, label %in_bounds, label %out_of_bounds2, !prof !{!"branch_weights", i32 1000, i32 0} - -in_bounds: - ret void - -out_of_bounds: - call void @foo(i64 0) - unreachable - -out_of_bounds2: - call void @foo(i64 1) - unreachable -} - -; As written, this one can't trigger today. It would require us to duplicate -; the %val1 load down two paths and that's not implemented yet. -define i64 @test3(i32 %length.i, i32 %i, i64* %base) { -; CHECK-LABEL: @test3 - %var29 = icmp slt i32 %i, %length.i -; CHECK: br i1 %var29, label %next, label %out_of_bounds - br i1 %var29, label %next, label %out_of_bounds, !prof !{!"branch_weights", i32 1000, i32 0} - -next: -; CHECK-LABEL: next: - %addr1 = getelementptr i64, i64* %base, i32 %i - %val1 = load i64, i64* %addr1 - %iplus1 = add nsw i32 %i, 1 - %var30 = icmp slt i32 %iplus1, %length.i -; CHECK: br i1 %var30, label %in_bounds, label %out_of_bounds2 - br i1 %var30, label %in_bounds, label %out_of_bounds2, !prof !{!"branch_weights", i32 1000, i32 0} - -in_bounds: - %addr2 = getelementptr i64, i64* %base, i32 %iplus1 - %val2 = load i64, i64* %addr2 - %res = sub i64 %val1, %val2 - ret i64 %res - -out_of_bounds: - call void @foo(i64 0) - unreachable - -out_of_bounds2: - call void @foo(i64 %val1) - unreachable -} - -declare void @foo(i64) - |

