[llvm] [ValueTracking] Prove constant-offset PtrAdd into known-size allocation is not poison. (PR #187825)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 29 01:11:49 PDT 2026


================
@@ -7798,6 +7798,33 @@ static bool isGuaranteedNotToBeUndefOrPoison(
       isa<Function>(StrippedV) || isa<ConstantPointerNull>(StrippedV))
     return true;
 
+  // A GEP matching with PtrAdd into a known-size allocation cannot produce
+  // poison if the constant offset in bytes is non-negative, within the
+  // allocated range, and does not wrap at truncation to the pointer index type.
+  // Note that for PtrAdd, the offset in bytes is equal to the first & only
+  // index, and when the index is non-negative, no signed wrap (nusw) implies no
+  // unsigned wrap (nuw).
----------------
nikic wrote:

This does not account for `inrange`.

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


More information about the llvm-commits mailing list