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