[llvm] [InferAddressSpaces] Handle unconverted ptrmask (PR #140802)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 2 05:48:14 PDT 2025


================
@@ -151,6 +152,34 @@ class TargetTransformInfoImplBase {
   }
 
   virtual bool isNoopAddrSpaceCast(unsigned, unsigned) const { return false; }
+
+  // Assuming that the cast between the two given addrspaces is not a noop,
+  // calculate the width of the given mask value so that it can be applied to
+  // the destination addrspace. In case it cannot be applied since the cast
+  // between the two addrspaces is invalid or the mask value is larger than the
+  // resulting addrspace bit-width, return an empty optional.
+  //
+  // Note that this currently expects the addrspaces to be integral. In case one
+  // of them isn't, an empty optional is returned.
+  virtual std::optional<uint64_t>
----------------
arsenm wrote:

This is a confusing interface that doesn't really generalize beyond this specific case. It's not clear what mask means. Instead, can we just provide a target implementation of computeKnownBits for AddrSpaceCast, and let the ptrmask handling code work out the consequences of that? 

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


More information about the llvm-commits mailing list