[llvm] [NFC][Analysis] Use `isa<ConstantPointerNull>` for null pointer checks (PR #197544)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 12:47:00 PDT 2026


================
@@ -1649,7 +1649,7 @@ Constant *llvm::ConstantFoldCastOperand(unsigned Opcode, Constant *C,
         APInt BaseOffset(BitWidth, 0);
         auto *Base = cast<Constant>(GEP->stripAndAccumulateConstantOffsets(
             DL, BaseOffset, /*AllowNonInbounds=*/true));
-        if (Base->isNullValue()) {
+        if (isa<ConstantPointerNull>(Base)) {
----------------
shiltian wrote:

I'm not sure about this one actually. What would be the semantics of GEP of a `nullptr` after we change the semantic?

https://github.com/llvm/llvm-project/pull/197544


More information about the llvm-commits mailing list