@@ -2256,6 +2256,7 @@ emitTransformedIndex(IRBuilderBase &B, Value *Index, Value *StartValue,
2256
2256
Value *Step,
2257
2257
InductionDescriptor::InductionKind InductionKind,
2258
2258
const BinaryOperator *InductionBinOp) {
2259
+ using namespace llvm ::PatternMatch;
2259
2260
Type *StepTy = Step->getType ();
2260
2261
Value *CastedIndex = StepTy->isIntegerTy ()
2261
2262
? B.CreateSExtOrTrunc (Index, StepTy)
@@ -2273,12 +2274,10 @@ emitTransformedIndex(IRBuilderBase &B, Value *Index, Value *StartValue,
2273
2274
// cases only.
2274
2275
auto CreateAdd = [&B](Value *X, Value *Y) {
2275
2276
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;
2282
2281
return B.CreateAdd (X, Y);
2283
2282
};
2284
2283
@@ -2287,12 +2286,10 @@ emitTransformedIndex(IRBuilderBase &B, Value *Index, Value *StartValue,
2287
2286
auto CreateMul = [&B](Value *X, Value *Y) {
2288
2287
assert (X->getType ()->getScalarType () == Y->getType () &&
2289
2288
" 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;
2296
2293
VectorType *XVTy = dyn_cast<VectorType>(X->getType ());
2297
2294
if (XVTy && !isa<VectorType>(Y->getType ()))
2298
2295
Y = B.CreateVectorSplat (XVTy->getElementCount (), Y);
0 commit comments