@@ -846,31 +846,13 @@ struct StreamingVLOpConversion
846846 ConversionPatternRewriter &rewriter) const override {
847847 auto loc = streamingVlOp.getLoc ();
848848 auto i64Type = rewriter.getI64Type ();
849- auto *intrOp = [&]() -> Operation * {
850- auto cntsd = arm_sme::aarch64_sme_cntsd::create (rewriter, loc, i64Type);
851- switch (streamingVlOp.getTypeSize ()) {
852- case arm_sme::TypeSize::Byte: {
853- auto mul = arith::ConstantIndexOp::create (rewriter, loc, 8 );
854- auto mul64 = arith::IndexCastOp::create (rewriter, loc, i64Type, mul);
855- return arith::MulIOp::create (rewriter, loc, cntsd, mul64);
856- }
857- case arm_sme::TypeSize::Half: {
858- auto mul = arith::ConstantIndexOp::create (rewriter, loc, 4 );
859- auto mul64 = arith::IndexCastOp::create (rewriter, loc, i64Type, mul);
860- return arith::MulIOp::create (rewriter, loc, cntsd, mul64);
861- }
862- case arm_sme::TypeSize::Word: {
863- auto mul = arith::ConstantIndexOp::create (rewriter, loc, 2 );
864- auto mul64 = arith::IndexCastOp::create (rewriter, loc, i64Type, mul);
865- return arith::MulIOp::create (rewriter, loc, cntsd, mul64);
866- }
867- case arm_sme::TypeSize::Double:
868- return cntsd;
869- }
870- llvm_unreachable (" unknown type size in StreamingVLOpConversion" );
871- }();
872- rewriter.replaceOpWithNewOp <arith::IndexCastOp>(
873- streamingVlOp, rewriter.getIndexType (), intrOp->getResult (0 ));
849+ auto cntsd = arm_sme::aarch64_sme_cntsd::create (rewriter, loc, i64Type);
850+ auto cntsdIdx = arith::IndexCastOp::create (rewriter, loc,
851+ rewriter.getIndexType (), cntsd);
852+ auto scale = arith::ConstantIndexOp::create (
853+ rewriter, loc,
854+ 8 / arm_sme::getSizeInBytes (streamingVlOp.getTypeSize ()));
855+ rewriter.replaceOpWithNewOp <arith::MulIOp>(streamingVlOp, cntsdIdx, scale);
874856 return success ();
875857 }
876858};
0 commit comments