[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 11:44:52 PST 2018


fhahn added inline comments.


================
Comment at: lib/Analysis/ValueTracking.cpp:2024
+    // Look through various operations and instructions which do not alter the
+    // value, or at least not the nullness property of the value (sext/zext).
+    if (const BitCastOperator *BCO = dyn_cast<BitCastOperator>(V))
----------------
The dyn_casts are not strictly necessary I think and using a switch on the opcode might be a little bit more compact, together with getOperand(0). But it doesn't really make a big difference.


================
Comment at: lib/Analysis/ValueTracking.cpp:2028
+
+    if (const AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(V))
+      return isKnownNonZero(ASC->getPointerOperand(), Depth, Q);
----------------
jdoerfert wrote:
> fhahn wrote:
> > 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.`
> Agreed, I'll remove this again.
I think it would be worth adding a separate file to test the various combinations of supported/unsupported casts.


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