[llvm] [IRBuilder][GlobalISel] Add byte ptr cast support in IRBuilder (PR #222049)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 14:49:14 PDT 2026


================
@@ -140,9 +146,7 @@ Value *IRBuilderBase::CreateBitPreservingCastChain(const DataLayout &DL,
   };
 
   // See if we need inttoptr for this type pair. May require additional bitcast.
-  bool OldIsIntLike =
-      OldTy->isIntOrIntVectorTy() || OldTy->isByteOrByteVectorTy();
-  if (OldIsIntLike && NewTy->isPtrOrPtrVectorTy()) {
+  if (OldTy->isIntOrIntVectorTy() && NewTy->isPtrOrPtrVectorTy()) {
----------------
nikic wrote:

Combining those bitcasts needs to be prevented in isEliminableCastPair(). I don't think there is any fundamental problem here though? You generally can't just look through bitcasts. (The only place where we routinely used to do that is ptr-to-ptr bitcasts, and those are no longer of any relevance.)

We are not going to permit byte types in inttoptr/ptrtoint. I do expect that we will permit pointers in bitcasts (generally, including when casting to/from integer) in the future, after the dust has settled. (Even better, we could just allow arbitrary bitcasts between types of the same size.)

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


More information about the llvm-commits mailing list