aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2025-05-21 14:18:40 +0200
committerGitHub <noreply@github.com>2025-05-21 14:18:40 +0200
commit9f8d798942e7679ca265efb23a7f655936d19a49 (patch)
treed4147e46f0c3f9196436f9845205d53a1e453727
parentff46a474968e6613ae9846088aa99e4459d598e9 (diff)
downloadllvm-9f8d798942e7679ca265efb23a7f655936d19a49.zip
llvm-9f8d798942e7679ca265efb23a7f655936d19a49.tar.gz
llvm-9f8d798942e7679ca265efb23a7f655936d19a49.tar.bz2
InferAddressSpaces: Stop trying to insert pointer bitcasts (#140873)
-rw-r--r--llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index d3771c09..1b7cecc 100644
--- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -660,8 +660,6 @@ Value *InferAddressSpacesImpl::cloneInstructionWithNewAddressSpace(
// Therefore, the inferred address space must be the source space, according
// to our algorithm.
assert(Src->getType()->getPointerAddressSpace() == NewAddrSpace);
- if (Src->getType() != NewPtrType)
- return new BitCastInst(Src, NewPtrType);
return Src;
}
@@ -739,7 +737,7 @@ Value *InferAddressSpacesImpl::cloneInstructionWithNewAddressSpace(
// If we had a no-op inttoptr/ptrtoint pair, we may still have inferred a
// source address space from a generic pointer source need to insert a cast
// back.
- return CastInst::CreatePointerBitCastOrAddrSpaceCast(Src, NewPtrType);
+ return new AddrSpaceCastInst(Src, NewPtrType);
}
default:
llvm_unreachable("Unexpected opcode");
@@ -764,7 +762,7 @@ static Value *cloneConstantExprWithNewAddressSpace(
// to our algorithm.
assert(CE->getOperand(0)->getType()->getPointerAddressSpace() ==
NewAddrSpace);
- return ConstantExpr::getBitCast(CE->getOperand(0), TargetType);
+ return CE->getOperand(0);
}
if (CE->getOpcode() == Instruction::BitCast) {
@@ -777,7 +775,7 @@ static Value *cloneConstantExprWithNewAddressSpace(
assert(isNoopPtrIntCastPair(cast<Operator>(CE), *DL, TTI));
Constant *Src = cast<ConstantExpr>(CE->getOperand(0))->getOperand(0);
assert(Src->getType()->getPointerAddressSpace() == NewAddrSpace);
- return ConstantExpr::getBitCast(Src, TargetType);
+ return Src;
}
// Computes the operands of the new constant expression.