mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
Canonicalize addrspacecast ConstExpr between different pointer types
As a follow-up to r210375 which canonicalizes addrspacecast instructions, this patch canonicalizes addrspacecast constant expressions. Given clang uses ConstantExpr::getAddrSpaceCast to emit addrspacecast cosntant expressions, this patch is also a step towards having the frontend emit canonicalized addrspacecasts. Piggyback a minor refactor in InstCombineCasts.cpp Update three affected tests in addrspacecast-alias.ll, access-non-generic.ll and constant-fold-gep.ll and added one new test in constant-fold-address-space-pointer.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211004 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1919,8 +1919,10 @@ Instruction *InstCombiner::visitAddrSpaceCast(AddrSpaceCastInst &CI) {
|
||||
Type *DestElemTy = DestTy->getElementType();
|
||||
if (SrcTy->getElementType() != DestElemTy) {
|
||||
Type *MidTy = PointerType::get(DestElemTy, SrcTy->getAddressSpace());
|
||||
if (CI.getType()->isVectorTy()) // Handle vectors of pointers.
|
||||
MidTy = VectorType::get(MidTy, CI.getType()->getVectorNumElements());
|
||||
if (VectorType *VT = dyn_cast<VectorType>(CI.getType())) {
|
||||
// Handle vectors of pointers.
|
||||
MidTy = VectorType::get(MidTy, VT->getNumElements());
|
||||
}
|
||||
|
||||
Value *NewBitCast = Builder->CreateBitCast(Src, MidTy);
|
||||
return new AddrSpaceCastInst(NewBitCast, CI.getType());
|
||||
|
Reference in New Issue
Block a user