[PATCH] D54956: [ValueTracking] Look through casts when determining non-nullness
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 27 09:49:59 PST 2018
jdoerfert created this revision.
jdoerfert added reviewers: fhahn, nlopes, sanjoy, spatel.
Herald added a subscriber: bollu.
Bitcast, address space cast and ptr2int instructions will not alter the
value of their operand and can therefore be looked through to determine
non-nullness.
Repository:
rL LLVM
https://reviews.llvm.org/D54956
Files:
lib/Analysis/ValueTracking.cpp
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<BitCastOperator>(V))
+ return isKnownNonZero(BCO->getOperand(0), Depth, Q);
+
+ if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V))
+ return isKnownNonZero(ASC->getPointerOperand(), Depth, Q);
+
+ if (const PtrToIntOperator *P2I = dyn_cast<PtrToIntOperator>(V))
+ return isKnownNonZero(P2I->getPointerOperand(), Depth, Q);
+ }
+
if (const GEPOperator *GEP = dyn_cast<GEPOperator>(V))
if (isGEPKnownNonNull(GEP, Depth, Q))
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54956.175515.patch
Type: text/x-patch
Size: 910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181127/07a66cca/attachment.bin>
More information about the llvm-commits
mailing list