Skip to content

Commit 6f9d557

Browse files
committed
[instcombine] Cleanup foldAllocaCmp slightly [NFC]
1 parent 8e7247a commit 6f9d557

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,8 +1006,7 @@ Instruction *InstCombinerImpl::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
10061006
}
10071007

10081008
Instruction *InstCombinerImpl::foldAllocaCmp(ICmpInst &ICI,
1009-
const AllocaInst *Alloca,
1010-
const Value *Other) {
1009+
const AllocaInst *Alloca) {
10111010
assert(ICI.isEquality() && "Cannot fold non-equality comparison.");
10121011

10131012
// It would be tempting to fold away comparisons between allocas and any
@@ -1076,10 +1075,9 @@ Instruction *InstCombinerImpl::foldAllocaCmp(ICmpInst &ICI,
10761075
}
10771076
}
10781077

1079-
Type *CmpTy = CmpInst::makeCmpResultType(Other->getType());
1080-
return replaceInstUsesWith(
1081-
ICI,
1082-
ConstantInt::get(CmpTy, !CmpInst::isTrueWhenEqual(ICI.getPredicate())));
1078+
auto *Res = ConstantInt::get(ICI.getType(),
1079+
!CmpInst::isTrueWhenEqual(ICI.getPredicate()));
1080+
return replaceInstUsesWith(ICI, Res);
10831081
}
10841082

10851083
/// Fold "icmp pred (X+C), X".
@@ -6061,10 +6059,10 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
60616059
if (Op0->getType()->isPointerTy() && I.isEquality()) {
60626060
assert(Op1->getType()->isPointerTy() && "Comparing pointer with non-pointer?");
60636061
if (auto *Alloca = dyn_cast<AllocaInst>(getUnderlyingObject(Op0)))
6064-
if (Instruction *New = foldAllocaCmp(I, Alloca, Op1))
6062+
if (Instruction *New = foldAllocaCmp(I, Alloca))
60656063
return New;
60666064
if (auto *Alloca = dyn_cast<AllocaInst>(getUnderlyingObject(Op1)))
6067-
if (Instruction *New = foldAllocaCmp(I, Alloca, Op0))
6065+
if (Instruction *New = foldAllocaCmp(I, Alloca))
60686066
return New;
60696067
}
60706068

llvm/lib/Transforms/InstCombine/InstCombineInternal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
650650

651651
Instruction *foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
652652
ICmpInst::Predicate Cond, Instruction &I);
653-
Instruction *foldAllocaCmp(ICmpInst &ICI, const AllocaInst *Alloca,
654-
const Value *Other);
653+
Instruction *foldAllocaCmp(ICmpInst &ICI, const AllocaInst *Alloca);
655654
Instruction *foldCmpLoadFromIndexedGlobal(LoadInst *LI,
656655
GetElementPtrInst *GEP,
657656
GlobalVariable *GV, CmpInst &ICI,

0 commit comments

Comments
 (0)