mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-06 06:33:24 +00:00
commonPointerCast cleanups to make address space change easier
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188719 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b937c55e93
commit
5c40cc2e1e
@ -1370,15 +1370,21 @@ Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) {
|
|||||||
return &CI;
|
return &CI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!TD)
|
||||||
|
return commonCastTransforms(CI);
|
||||||
|
|
||||||
// If the GEP has a single use, and the base pointer is a bitcast, and the
|
// If the GEP has a single use, and the base pointer is a bitcast, and the
|
||||||
// GEP computes a constant offset, see if we can convert these three
|
// GEP computes a constant offset, see if we can convert these three
|
||||||
// instructions into fewer. This typically happens with unions and other
|
// instructions into fewer. This typically happens with unions and other
|
||||||
// non-type-safe code.
|
// non-type-safe code.
|
||||||
APInt Offset(TD ? TD->getPointerSizeInBits() : 1, 0);
|
unsigned OffsetBits = TD->getPointerSizeInBits();
|
||||||
if (TD && GEP->hasOneUse() && isa<BitCastInst>(GEP->getOperand(0)) &&
|
APInt Offset(OffsetBits, 0);
|
||||||
|
BitCastInst *BCI = dyn_cast<BitCastInst>(GEP->getOperand(0));
|
||||||
|
if (GEP->hasOneUse() &&
|
||||||
|
BCI &&
|
||||||
GEP->accumulateConstantOffset(*TD, Offset)) {
|
GEP->accumulateConstantOffset(*TD, Offset)) {
|
||||||
// Get the base pointer input of the bitcast, and the type it points to.
|
// Get the base pointer input of the bitcast, and the type it points to.
|
||||||
Value *OrigBase = cast<BitCastInst>(GEP->getOperand(0))->getOperand(0);
|
Value *OrigBase = BCI->getOperand(0);
|
||||||
Type *GEPIdxTy = OrigBase->getType()->getPointerElementType();
|
Type *GEPIdxTy = OrigBase->getType()->getPointerElementType();
|
||||||
SmallVector<Value*, 8> NewIndices;
|
SmallVector<Value*, 8> NewIndices;
|
||||||
if (FindElementAtOffset(GEPIdxTy, Offset.getSExtValue(), NewIndices)) {
|
if (FindElementAtOffset(GEPIdxTy, Offset.getSExtValue(), NewIndices)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user