@@ -1006,8 +1006,7 @@ Instruction *InstCombinerImpl::foldGEPICmp(GEPOperator *GEPLHS, Value *RHS,
10061006}
10071007
10081008Instruction *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
0 commit comments