Avoid dropping the address space when InstCombine optimizes memset

llvm-svn: 122215
This commit is contained in:
Mon P Wang 2010-12-20 01:05:30 +00:00
parent 16ea7f257f
commit 4ab0ea216d

View File

@ -234,7 +234,9 @@ Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) {
const Type *ITy = IntegerType::get(MI->getContext(), Len*8); // n=1 -> i8.
Value *Dest = MI->getDest();
Dest = Builder->CreateBitCast(Dest, PointerType::getUnqual(ITy));
unsigned DstAddrSp = cast<PointerType>(Dest->getType())->getAddressSpace();
Type *NewDstPtrTy = PointerType::get(ITy, DstAddrSp);
Dest = Builder->CreateBitCast(Dest, NewDstPtrTy);
// Alignment 0 is identity for alignment 1 for memset, but not store.
if (Alignment == 0) Alignment = 1;