@@ -2256,6 +2256,7 @@ emitTransformedIndex(IRBuilderBase &B, Value *Index, Value *StartValue,
22562256 Value *Step,
22572257 InductionDescriptor::InductionKind InductionKind,
22582258 const BinaryOperator *InductionBinOp) {
2259+ using namespace llvm ::PatternMatch;
22592260 Type *StepTy = Step->getType ();
22602261 Value *CastedIndex = StepTy->isIntegerTy ()
22612262 ? B.CreateSExtOrTrunc (Index, StepTy)
@@ -2273,12 +2274,10 @@ emitTransformedIndex(IRBuilderBase &B, Value *Index, Value *StartValue,
22732274 // cases only.
22742275 auto CreateAdd = [&B](Value *X, Value *Y) {
22752276 assert (X->getType () == Y->getType () && " Types don't match!" );
2276- if (auto *CX = dyn_cast<ConstantInt>(X))
2277- if (CX->isZero ())
2278- return Y;
2279- if (auto *CY = dyn_cast<ConstantInt>(Y))
2280- if (CY->isZero ())
2281- return X;
2277+ if (match (X, m_ZeroInt ()))
2278+ return Y;
2279+ if (match (Y, m_ZeroInt ()))
2280+ return X;
22822281 return B.CreateAdd (X, Y);
22832282 };
22842283
@@ -2287,12 +2286,10 @@ emitTransformedIndex(IRBuilderBase &B, Value *Index, Value *StartValue,
22872286 auto CreateMul = [&B](Value *X, Value *Y) {
22882287 assert (X->getType ()->getScalarType () == Y->getType () &&
22892288 " Types don't match!" );
2290- if (auto *CX = dyn_cast<ConstantInt>(X))
2291- if (CX->isOne ())
2292- return Y;
2293- if (auto *CY = dyn_cast<ConstantInt>(Y))
2294- if (CY->isOne ())
2295- return X;
2289+ if (match (X, m_One ()))
2290+ return Y;
2291+ if (match (Y, m_One ()))
2292+ return X;
22962293 VectorType *XVTy = dyn_cast<VectorType>(X->getType ());
22972294 if (XVTy && !isa<VectorType>(Y->getType ()))
22982295 Y = B.CreateVectorSplat (XVTy->getElementCount (), Y);
0 commit comments