Index: lib/Analysis/ValueTracking.cpp =================================================================== --- lib/Analysis/ValueTracking.cpp +++ lib/Analysis/ValueTracking.cpp @@ -2016,6 +2016,18 @@ if (isKnownNonNullFromDominatingCondition(V, Q.CxtI, Q.DT)) return true; + { + // Look through operations that do not alter the value. + if (const BitCastOperator *BCO = dyn_cast(V)) + return isKnownNonZero(BCO->getOperand(0), Depth, Q); + + if (const AddrSpaceCastInst *ASC = dyn_cast(V)) + return isKnownNonZero(ASC->getPointerOperand(), Depth, Q); + + if (const PtrToIntOperator *P2I = dyn_cast(V)) + return isKnownNonZero(P2I->getPointerOperand(), Depth, Q); + } + if (const GEPOperator *GEP = dyn_cast(V)) if (isGEPKnownNonNull(GEP, Depth, Q)) return true;