[llvm] [IR] Require that ptrmask mask matches pointer index size (PR #69343)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 18 12:01:30 PDT 2023


================
@@ -26965,10 +26966,20 @@ to facilitate alias analysis and underlying-object detection.
 Semantics:
 """"""""""
 
-The result of ``ptrmask(ptr, mask)`` is equivalent to
-``getelementptr ptr, (ptrtoint(ptr) & mask) - ptrtoint(ptr)``. Both the returned
-pointer(s) and the first argument are based on the same underlying object (for more
-information on the *based on* terminology see
+The result of ``ptrmask(%ptr, %mask)`` is equivalent to the following expansion,
+where ``iPtrIdx`` is the index type size of the pointer::
+
+    %intptr = ptrtoint ptr %ptr to iPtrIdx ; this may truncate
+    %masked = and iPtrIdx %intptr, %mask
+    %diff = sub iPtrIdx %masked, %intptr
----------------
jayfoad wrote:

OK but I don't see that documented in the semantics: https://llvm.org/docs/LangRef.html#id234

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


More information about the llvm-commits mailing list