Skip to content

Commit b75da36

Browse files
committed
More early return
1 parent c257409 commit b75da36

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,8 @@ void InferAddressSpacesImpl::performPointerReplacement(
11871187
if (CurUser == NewV)
11881188
return;
11891189

1190-
if (auto *CurUserI = dyn_cast<Instruction>(CurUser);
1191-
CurUserI && CurUserI->getFunction() != F)
1190+
auto *CurUserI = dyn_cast<Instruction>(CurUser);
1191+
if (!CurUserI || CurUserI->getFunction() != F)
11921192
return;
11931193

11941194
// Handle more complex cases like intrinsic that need to be remangled.
@@ -1202,10 +1202,7 @@ void InferAddressSpacesImpl::performPointerReplacement(
12021202
return;
12031203
}
12041204

1205-
if (!isa<Instruction>(CurUser))
1206-
return;
1207-
1208-
if (ICmpInst *Cmp = dyn_cast<ICmpInst>(CurUser)) {
1205+
if (ICmpInst *Cmp = dyn_cast<ICmpInst>(CurUserI)) {
12091206
// If we can infer that both pointers are in the same addrspace,
12101207
// transform e.g.
12111208
// %cmp = icmp eq float* %p, %q
@@ -1236,7 +1233,7 @@ void InferAddressSpacesImpl::performPointerReplacement(
12361233
}
12371234
}
12381235

1239-
if (AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(CurUser)) {
1236+
if (AddrSpaceCastInst *ASC = dyn_cast<AddrSpaceCastInst>(CurUserI)) {
12401237
unsigned NewAS = NewV->getType()->getPointerAddressSpace();
12411238
if (ASC->getDestAddressSpace() == NewAS) {
12421239
ASC->replaceAllUsesWith(NewV);
@@ -1264,8 +1261,8 @@ void InferAddressSpacesImpl::performPointerReplacement(
12641261
CurUser->replaceUsesOfWith(
12651262
V, new AddrSpaceCastInst(NewV, V->getType(), "", InsertPos));
12661263
} else {
1267-
CurUser->replaceUsesOfWith(V, ConstantExpr::getAddrSpaceCast(
1268-
cast<Constant>(NewV), V->getType()));
1264+
CurUserI->replaceUsesOfWith(
1265+
V, ConstantExpr::getAddrSpaceCast(cast<Constant>(NewV), V->getType()));
12691266
}
12701267
}
12711268

0 commit comments

Comments
 (0)