There are places where the inductive range check elimination pass depends on two llvm::Values or llvm::SCEVs to be of the same llvm::Type when they do not need to be. This patch relaxes those restrictions, and adds test cases to trigger those paths.
Three things to note:
- These issues were found by bootstrapping clang with IRCE running in the -O3 pass ordering.
- I will follow up with a change that factors out an independent Range construct -- things like Range.first->getType() are ugly.
- I have not added a test case that exercises the CIVComparedToSCEV->getType() != LatchCount->getType()) part of the change. That part of the change is needed when -indvars widens the induction variable, but leaves behind the old cached value for a loop's backedge taken count in scalar evolution (so the types mismatch but the actual value of the backedge-taken-count is still accurate). So far I have not managed to reproduce this problem outside of clang.