Skip to content

Commit

Permalink
[LSR] Simplify type check for opaque pointers (NFC)
Browse files Browse the repository at this point in the history
For pointer types, checking the address space is the same as
type equality now, so we no longer need the special case.
  • Loading branch information
nikic committed Sep 22, 2023
1 parent 8f54861 commit d35e5af
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2788,18 +2788,6 @@ static Value *getWideOperand(Value *Oper) {
return Oper;
}

/// Return true if we allow an IV chain to include both types.
static bool isCompatibleIVType(Value *LVal, Value *RVal) {
Type *LType = LVal->getType();
Type *RType = RVal->getType();
return (LType == RType) || (LType->isPointerTy() && RType->isPointerTy() &&
// Different address spaces means (possibly)
// different types of the pointer implementation,
// e.g. i16 vs i32 so disallow that.
(LType->getPointerAddressSpace() ==
RType->getPointerAddressSpace()));
}

/// Return an approximation of this SCEV expression's "base", or NULL for any
/// constant. Returning the expression itself is conservative. Returning a
/// deeper subexpression is more precise and valid as long as it isn't less
Expand Down Expand Up @@ -2979,7 +2967,7 @@ void LSRInstance::ChainInstruction(Instruction *UserInst, Instruction *IVOper,
continue;

Value *PrevIV = getWideOperand(Chain.Incs.back().IVOperand);
if (!isCompatibleIVType(PrevIV, NextIV))
if (PrevIV->getType() != NextIV->getType())
continue;

// A phi node terminates a chain.
Expand Down Expand Up @@ -3273,7 +3261,7 @@ void LSRInstance::GenerateIVChain(const IVChain &Chain,
// do this if we also found a wide value for the head of the chain.
if (isa<PHINode>(Chain.tailUserInst())) {
for (PHINode &Phi : L->getHeader()->phis()) {
if (!isCompatibleIVType(&Phi, IVSrc))
if (Phi.getType() != IVSrc->getType())
continue;
Instruction *PostIncV = dyn_cast<Instruction>(
Phi.getIncomingValueForBlock(L->getLoopLatch()));
Expand Down

0 comments on commit d35e5af

Please sign in to comment.