mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-28 06:24:57 +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:
@ -529,7 +529,10 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
|
||||
// Try hard to fold cast of cast because they are often eliminable.
|
||||
if (unsigned newOpc = foldConstantCastPair(opc, CE, DestTy))
|
||||
return ConstantExpr::getCast(newOpc, CE->getOperand(0), DestTy);
|
||||
} else if (CE->getOpcode() == Instruction::GetElementPtr) {
|
||||
} else if (CE->getOpcode() == Instruction::GetElementPtr &&
|
||||
// Do not fold addrspacecast (gep 0, .., 0). It might make the
|
||||
// addrspacecast uncanonicalized.
|
||||
opc != Instruction::AddrSpaceCast) {
|
||||
// If all of the indexes in the GEP are null values, there is no pointer
|
||||
// adjustment going on. We might as well cast the source pointer.
|
||||
bool isAllNull = true;
|
||||
|
Reference in New Issue
Block a user