[PATCH] D54956: [ValueTracking] Look through casts when determining non-nullness

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 27 10:40:13 PST 2018


fhahn added inline comments.


================
Comment at: lib/Analysis/ValueTracking.cpp:2028
+
+    if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V))
+      return isKnownNonZero(ASC->getPointerOperand(), Depth, Q);
----------------
Not sure if that is safe, according to LangRef: `The ‘addrspacecast’ instruction converts the pointer value ptrval to type pty2. It can be a no-op cast or a complex value modification, depending on the target and the address space pair.`


================
Comment at: lib/Analysis/ValueTracking.cpp:2031
+
+    if (const PtrToIntOperator *P2I = dyn_cast<PtrToIntOperator>(V))
+      return isKnownNonZero(P2I->getPointerOperand(), Depth, Q);
----------------
ptrtoint & inttoptr do truncate if the target type is smaller than the value type. Wouldn't it be possible that this changes a non-zero value to a zero value ( if we truncate all non-zero bits?)


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54956/new/

https://reviews.llvm.org/D54956





More information about the llvm-commits mailing list