Index: lib/Transforms/InstCombine/InstCombineCasts.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineCasts.cpp +++ lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -1820,6 +1820,10 @@ auto *LI = dyn_cast(IncValue); if (LI) { + // If the loaded value is used as the load address in the same + // instruction, bitcast is necessary to change the value type. + if (LI->getOperand(0) == &CI) + return nullptr; if (LI->hasOneUse() && LI->isSimple()) continue; // If a LoadInst has more than one use, changing the type of loaded