Skip to content

Commit a0ce438

Browse files
authored
[LICM] Simplify isLoadInvariantInLoop given opaque pointers (#65597)
Since we no longer support typed pointers in LLVM IR, the PtrASXTy in isLoadInvariantInLoop was set to be equal to Addr->getType() (an opaque ptr in the same address space). That made the loop looking through bitcasts redundant.
1 parent aca9019 commit a0ce438

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

llvm/lib/Transforms/Scalar/LICM.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ bool llvm::hoistRegion(DomTreeNode *N, AAResults *AA, LoopInfo *LI,
10391039
// invariant.start has no uses.
10401040
static bool isLoadInvariantInLoop(LoadInst *LI, DominatorTree *DT,
10411041
Loop *CurLoop) {
1042-
Value *Addr = LI->getOperand(0);
1042+
Value *Addr = LI->getPointerOperand();
10431043
const DataLayout &DL = LI->getModule()->getDataLayout();
10441044
const TypeSize LocSizeInBits = DL.getTypeSizeInBits(LI->getType());
10451045

@@ -1055,21 +1055,6 @@ static bool isLoadInvariantInLoop(LoadInst *LI, DominatorTree *DT,
10551055
if (LocSizeInBits.isScalable())
10561056
return false;
10571057

1058-
// if the type is ptr addrspace(x), we know this is the type of
1059-
// llvm.invariant.start operand
1060-
auto *PtrASXTy = PointerType::get(LI->getContext(),
1061-
LI->getPointerAddressSpace());
1062-
unsigned BitcastsVisited = 0;
1063-
// Look through bitcasts until we reach the PtrASXTy type (this is
1064-
// invariant.start operand type).
1065-
// FIXME: We shouldn't really find such bitcasts with opaque pointers.
1066-
while (Addr->getType() != PtrASXTy) {
1067-
auto *BC = dyn_cast<BitCastInst>(Addr);
1068-
// Avoid traversing high number of bitcast uses.
1069-
if (++BitcastsVisited > MaxNumUsesTraversed || !BC)
1070-
return false;
1071-
Addr = BC->getOperand(0);
1072-
}
10731058
// If we've ended up at a global/constant, bail. We shouldn't be looking at
10741059
// uselists for non-local Values in a loop pass.
10751060
if (isa<Constant>(Addr))

0 commit comments

Comments
 (0)