SCEV (and AA) has trouble understanding inttoptr/ptrtoint instructions and thus produces conservative analysis results, which blocks transformations such as loop vectorizer. See https://reviews.llvm.org/D37419 for background.
Instead of teaching SCEV to see through those bitcast operations, this patch improves instcombiner to eliminate those operations when possible.
I believe this line of code caused a clang crash with Windows EH:
https://llvm.org/pr45033
getFirstInsertionPt returns an iterator which may be an end iterator, which cannot be cast to Instruction*. This case arises for catchswitch blocks, which have no valid insertion point.
I will put together a fix, but I figured I should alert folks to this corner case to avoid such problems in the future.