Revert 250343 and 250344
authorPhilip Reames <listmail@philipreames.com>
Thu, 15 Oct 2015 16:51:00 +0000 (16:51 +0000)
committerPhilip Reames <listmail@philipreames.com>
Thu, 15 Oct 2015 16:51:00 +0000 (16:51 +0000)
commit1ad3dfdf95a5f4ada4f178ce6cb81d5ae3fb42d3
treec96f45d9d466704845b70dc8c0d401e3ab41561a
parentb72c6bad3c6d50fd5d0f24b704c05c8ab997d675
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...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250430 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/SimplifyCFG.cpp
test/Transforms/SimplifyCFG/fast-fallthrough.ll [deleted file]