[llvm] [InferAddressSpaces] apply InferAddressSpaces to inttoptr-zext-ptrtoint address expression. (PR #79108)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 12:01:54 PST 2024


================
@@ -300,6 +300,34 @@ static bool isNoopPtrIntCastPair(const Operator *I2P, const DataLayout &DL,
          (P2IOp0AS == I2PAS || TTI->isNoopAddrSpaceCast(P2IOp0AS, I2PAS));
 }
 
+// Check whether that's pointer bitcast using `ptrtoint`-`zext`-`inttoptr`
+static bool isZExtPtrIntCastPair(const Operator *I2P, const DataLayout &DL) {
----------------
arichardson wrote:

These two functions are almost the same, could they be merged and return the `ptrtoint` instruction or `nullptr` instead of bool? That would simplify the uses below.

Something like `static Operator *getNoopOrExtPtrIntCastPair(const Operator *I2P, const DataLayout &DL, const TargetTransformInfo *TTI)`?

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


More information about the llvm-commits mailing list