@@ -58,36 +58,38 @@ static void fixI8TruncUseChain(Instruction &I,
58
58
if (Trunc->getDestTy ()->isIntegerTy (8 )) {
59
59
ReplacedValues[Trunc] = Trunc->getOperand (0 );
60
60
ToRemove.push_back (Trunc);
61
+ return ;
61
62
}
62
63
}
63
- Value *NewInst = nullptr ;
64
+
64
65
if (auto *BO = dyn_cast<BinaryOperator>(&I)) {
65
66
if (!I.getType ()->isIntegerTy (8 ))
66
67
return ;
67
68
SmallVector<Value *> NewOperands;
68
69
ProcessOperands (NewOperands);
69
- NewInst =
70
+ Value * NewInst =
70
71
Builder.CreateBinOp (BO->getOpcode (), NewOperands[0 ], NewOperands[1 ]);
71
72
if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(&I)) {
72
73
if (OBO->hasNoSignedWrap ())
73
74
cast<BinaryOperator>(NewInst)->setHasNoSignedWrap ();
74
75
if (OBO->hasNoUnsignedWrap ())
75
76
cast<BinaryOperator>(NewInst)->setHasNoUnsignedWrap ();
76
77
}
78
+ ReplacedValues[BO] = NewInst;
79
+ ToRemove.push_back (BO);
80
+ return ;
77
81
}
78
82
79
83
if (auto *Cmp = dyn_cast<CmpInst>(&I)) {
80
84
if (!Cmp->getOperand (0 )->getType ()->isIntegerTy (8 ))
81
85
return ;
82
86
SmallVector<Value *> NewOperands;
83
87
ProcessOperands (NewOperands);
84
- NewInst =
88
+ Value * NewInst =
85
89
Builder.CreateCmp (Cmp->getPredicate (), NewOperands[0 ], NewOperands[1 ]);
86
90
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);
91
93
return ;
92
94
}
93
95
0 commit comments