Skip to content

Commit 2593167

Browse files
authored
Block hoisting bitcasts over non-integral ascast (#23)
1 parent 084cd0f commit 2593167

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2906,8 +2906,10 @@ Instruction *InstCombinerImpl::visitAddrSpaceCast(AddrSpaceCastInst &CI) {
29062906
Value *Src = CI.getOperand(0);
29072907
PointerType *SrcTy = cast<PointerType>(Src->getType()->getScalarType());
29082908
PointerType *DestTy = cast<PointerType>(CI.getType()->getScalarType());
2909+
bool isni = DL.isNonIntegralAddressSpace(SrcTy->getAddressSpace()) ||
2910+
DL.isNonIntegralAddressSpace(DestTy->getAddressSpace());
29092911

2910-
if (!SrcTy->hasSameElementTypeAs(DestTy)) {
2912+
if (!SrcTy->hasSameElementTypeAs(DestTy) && !isni) {
29112913
Type *MidTy =
29122914
PointerType::getWithSamePointeeType(DestTy, SrcTy->getAddressSpace());
29132915
// Handle vectors of pointers.

0 commit comments

Comments
 (0)