[llvm] 6f9d557 - [instcombine] Cleanup foldAllocaCmp slightly [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 18 18:49:45 PST 2022
Author: Philip Reames
Date: 2022-02-18T18:49:39-08:00
New Revision: 6f9d557e0835d884cdc343eef4ec4e86e96aca62
URL: https://github.com/llvm/llvm-project/commit/6f9d557e0835d884cdc343eef4ec4e86e96aca62
DIFF: https://github.com/llvm/llvm-project/commit/6f9d557e0835d884cdc343eef4ec4e86e96aca62.diff
LOG: [instcombine] Cleanup foldAllocaCmp slightly [NFC]
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index 46af7d8468922..13540a77b511c 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -1006,8 +1006,7 @@ Instruction *InstCombinerImpl::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
}
Instruction *InstCombinerImpl::foldAllocaCmp(ICmpInst &ICI,
- const AllocaInst *Alloca,
- const Value *Other) {
+ const AllocaInst *Alloca) {
assert(ICI.isEquality() && "Cannot fold non-equality comparison.");
// It would be tempting to fold away comparisons between allocas and any
@@ -1076,10 +1075,9 @@ Instruction *InstCombinerImpl::foldAllocaCmp(ICmpInst &ICI,
}
}
- Type *CmpTy = CmpInst::makeCmpResultType(Other->getType());
- return replaceInstUsesWith(
- ICI,
- ConstantInt::get(CmpTy, !CmpInst::isTrueWhenEqual(ICI.getPredicate())));
+ auto *Res = ConstantInt::get(ICI.getType(),
+ !CmpInst::isTrueWhenEqual(ICI.getPredicate()));
+ return replaceInstUsesWith(ICI, Res);
}
/// Fold "icmp pred (X+C), X".
@@ -6061,10 +6059,10 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
if (Op0->getType()->isPointerTy() && I.isEquality()) {
assert(Op1->getType()->isPointerTy() && "Comparing pointer with non-pointer?");
if (auto *Alloca = dyn_cast<AllocaInst>(getUnderlyingObject(Op0)))
- if (Instruction *New = foldAllocaCmp(I, Alloca, Op1))
+ if (Instruction *New = foldAllocaCmp(I, Alloca))
return New;
if (auto *Alloca = dyn_cast<AllocaInst>(getUnderlyingObject(Op1)))
- if (Instruction *New = foldAllocaCmp(I, Alloca, Op0))
+ if (Instruction *New = foldAllocaCmp(I, Alloca))
return New;
}
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 674d20461daff..e590a301fefc5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -650,8 +650,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
Instruction *foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
ICmpInst::Predicate Cond, Instruction &I);
- Instruction *foldAllocaCmp(ICmpInst &ICI, const AllocaInst *Alloca,
- const Value *Other);
+ Instruction *foldAllocaCmp(ICmpInst &ICI, const AllocaInst *Alloca);
Instruction *foldCmpLoadFromIndexedGlobal(LoadInst *LI,
GetElementPtrInst *GEP,
GlobalVariable *GV, CmpInst &ICI,
More information about the llvm-commits
mailing list