Skip to content

Commit d35e5af

Browse files
committed
[LSR] Simplify type check for opaque pointers (NFC)
For pointer types, checking the address space is the same as type equality now, so we no longer need the special case.
1 parent 8f54861 commit d35e5af

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,18 +2788,6 @@ static Value *getWideOperand(Value *Oper) {
27882788
return Oper;
27892789
}
27902790

2791-
/// Return true if we allow an IV chain to include both types.
2792-
static bool isCompatibleIVType(Value *LVal, Value *RVal) {
2793-
Type *LType = LVal->getType();
2794-
Type *RType = RVal->getType();
2795-
return (LType == RType) || (LType->isPointerTy() && RType->isPointerTy() &&
2796-
// Different address spaces means (possibly)
2797-
// different types of the pointer implementation,
2798-
// e.g. i16 vs i32 so disallow that.
2799-
(LType->getPointerAddressSpace() ==
2800-
RType->getPointerAddressSpace()));
2801-
}
2802-
28032791
/// Return an approximation of this SCEV expression's "base", or NULL for any
28042792
/// constant. Returning the expression itself is conservative. Returning a
28052793
/// deeper subexpression is more precise and valid as long as it isn't less
@@ -2979,7 +2967,7 @@ void LSRInstance::ChainInstruction(Instruction *UserInst, Instruction *IVOper,
29792967
continue;
29802968

29812969
Value *PrevIV = getWideOperand(Chain.Incs.back().IVOperand);
2982-
if (!isCompatibleIVType(PrevIV, NextIV))
2970+
if (PrevIV->getType() != NextIV->getType())
29832971
continue;
29842972

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

0 commit comments

Comments
 (0)