@@ -58,36 +58,38 @@ static void fixI8TruncUseChain(Instruction &I,
5858 if (Trunc->getDestTy ()->isIntegerTy (8 )) {
5959 ReplacedValues[Trunc] = Trunc->getOperand (0 );
6060 ToRemove.push_back (Trunc);
61+ return ;
6162 }
6263 }
63- Value *NewInst = nullptr ;
64+
6465 if (auto *BO = dyn_cast<BinaryOperator>(&I)) {
6566 if (!I.getType ()->isIntegerTy (8 ))
6667 return ;
6768 SmallVector<Value *> NewOperands;
6869 ProcessOperands (NewOperands);
69- NewInst =
70+ Value * NewInst =
7071 Builder.CreateBinOp (BO->getOpcode (), NewOperands[0 ], NewOperands[1 ]);
7172 if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(&I)) {
7273 if (OBO->hasNoSignedWrap ())
7374 cast<BinaryOperator>(NewInst)->setHasNoSignedWrap ();
7475 if (OBO->hasNoUnsignedWrap ())
7576 cast<BinaryOperator>(NewInst)->setHasNoUnsignedWrap ();
7677 }
78+ ReplacedValues[BO] = NewInst;
79+ ToRemove.push_back (BO);
80+ return ;
7781 }
7882
7983 if (auto *Cmp = dyn_cast<CmpInst>(&I)) {
8084 if (!Cmp->getOperand (0 )->getType ()->isIntegerTy (8 ))
8185 return ;
8286 SmallVector<Value *> NewOperands;
8387 ProcessOperands (NewOperands);
84- NewInst =
88+ Value * NewInst =
8589 Builder.CreateCmp (Cmp->getPredicate (), NewOperands[0 ], NewOperands[1 ]);
8690 Cmp->replaceAllUsesWith (NewInst);
87- }
88- if (NewInst) {
89- ReplacedValues[&I] = NewInst;
90- ToRemove.push_back (&I);
91+ ReplacedValues[Cmp] = NewInst;
92+ ToRemove.push_back (Cmp);
9193 return ;
9294 }
9395
0 commit comments