Function rewriteLoopExitValues contains a check on isValidRewrite which
describes some strange situation about SCEV messing up with GEPs, but no
test actually demonstrates this behavior. I wasn't able to find one by running
more than 5000 fuzz tests as well. The comment in this method doesn't give
any sound description of how and what may go wrong.
It was introduced by rL127839 without any associated test. The issue this patch
claims to fix (rdar://problem/9038671) cannot be found by now. The patch is pretty
big and it's unclear whether or not this particular check has anything to do with the
problem it was supposed to address.
There are two possible options:
1. This piece of code is obsolete by now. We should leave it as assert or just remove it later.is needed to make sure that SCEV does not convert the pattern
2`gep Base, (&p[n] - &p)` into `gep &p[n], Base - &p`. This piece of code really protects us from some nasty bug for which we don't have a unit test.roblem
In this case the check should be returned and the respective unit test should be addedhas been fixed in SCEV long ago, so this check is just obsolete.
This patch turns this piece of codeconverts it into an assertion to diagnose what of two options
above is true. We will either improve compile time or improve test coverage by checkingmake sure that the SCEV will
it innot mess up this case in the future.