Index: lib/CodeGen/IslNodeBuilder.cpp =================================================================== --- lib/CodeGen/IslNodeBuilder.cpp +++ lib/CodeGen/IslNodeBuilder.cpp @@ -1028,7 +1028,8 @@ auto *Ptr = AddressValue; auto Name = Ptr->getName(); - Ptr = Builder.CreatePointerCast(Ptr, Ty->getPointerTo(), Name + ".cast"); + auto AS = Ptr->getType()->getPointerAddressSpace(); + Ptr = Builder.CreatePointerCast(Ptr, Ty->getPointerTo(AS), Name + ".cast"); PreloadVal = Builder.CreateLoad(Ptr, Name + ".load"); if (LoadInst *PreloadInst = dyn_cast(PreloadVal)) PreloadInst->setAlignment(dyn_cast(AccInst)->getAlignment());