@@ -2428,22 +2428,33 @@ class FirConverter : public Fortran::lower::AbstractConverter {
24282428 {}, {}, {}, {});
24292429 }
24302430
2431+ // Enabling loop vectorization attribute.
2432+ mlir::LLVM::LoopVectorizeAttr
2433+ genLoopVectorizeAttr (mlir::BoolAttr disableAttr,
2434+ mlir::BoolAttr ivdepEnableAttr) {
2435+ mlir::LLVM::LoopVectorizeAttr va;
2436+ if (disableAttr || ivdepEnableAttr)
2437+ va = mlir::LLVM::LoopVectorizeAttr::get (builder->getContext (),
2438+ /* disable=*/ disableAttr, {}, {},
2439+ /* ivdepEnable*/ ivdepEnableAttr,
2440+ {}, {}, {}, {});
2441+ return va;
2442+ }
2443+
24312444 void addLoopAnnotationAttr (
24322445 IncrementLoopInfo &info,
24332446 llvm::SmallVectorImpl<const Fortran::parser::CompilerDirective *> &dirs) {
2434- mlir::LLVM::LoopVectorizeAttr va ;
2447+ mlir::BoolAttr disableVecAttr, ivdepEnableAttr ;
24352448 mlir::LLVM::LoopUnrollAttr ua;
24362449 mlir::LLVM::LoopUnrollAndJamAttr uja;
2450+ llvm::SmallVector<mlir::LLVM::AccessGroupAttr> aga;
24372451 bool has_attrs = false ;
24382452 for (const auto *dir : dirs) {
24392453 Fortran::common::visit (
24402454 Fortran::common::visitors{
24412455 [&](const Fortran::parser::CompilerDirective::VectorAlways &) {
2442- mlir::BoolAttr falseAttr =
2456+ disableVecAttr =
24432457 mlir::BoolAttr::get (builder->getContext (), false );
2444- va = mlir::LLVM::LoopVectorizeAttr::get (builder->getContext (),
2445- /* disable=*/ falseAttr,
2446- {}, {}, {}, {}, {}, {});
24472458 has_attrs = true ;
24482459 },
24492460 [&](const Fortran::parser::CompilerDirective::Unroll &u) {
@@ -2455,11 +2466,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
24552466 has_attrs = true ;
24562467 },
24572468 [&](const Fortran::parser::CompilerDirective::NoVector &u) {
2458- mlir::BoolAttr trueAttr =
2469+ disableVecAttr =
24592470 mlir::BoolAttr::get (builder->getContext (), true );
2460- va = mlir::LLVM::LoopVectorizeAttr::get (builder->getContext (),
2461- /* disable=*/ trueAttr,
2462- {}, {}, {}, {}, {}, {});
24632471 has_attrs = true ;
24642472 },
24652473 [&](const Fortran::parser::CompilerDirective::NoUnroll &u) {
@@ -2470,10 +2478,16 @@ class FirConverter : public Fortran::lower::AbstractConverter {
24702478 uja = genLoopUnrollAndJamAttr (/* unrollingFactor=*/ 0 );
24712479 has_attrs = true ;
24722480 },
2473-
2481+ [&](const Fortran::parser::CompilerDirective::IVDep &iv) {
2482+ ivdepEnableAttr =
2483+ mlir::BoolAttr::get (builder->getContext (), true );
2484+ has_attrs = true ;
2485+ },
24742486 [&](const auto &) {}},
24752487 dir->u );
24762488 }
2489+ mlir::LLVM::LoopVectorizeAttr va =
2490+ genLoopVectorizeAttr (disableVecAttr, ivdepEnableAttr);
24772491 mlir::LLVM::LoopAnnotationAttr la = mlir::LLVM::LoopAnnotationAttr::get (
24782492 builder->getContext (), {}, /* vectorize=*/ va, {}, /* unroll*/ ua,
24792493 /* unroll_and_jam*/ uja, {}, {}, {}, {}, {}, {}, {}, {}, {}, {});
@@ -3178,6 +3192,9 @@ class FirConverter : public Fortran::lower::AbstractConverter {
31783192 [&](const Fortran::parser::CompilerDirective::NoUnrollAndJam &) {
31793193 attachDirectiveToLoop (dir, &eval);
31803194 },
3195+ [&](const Fortran::parser::CompilerDirective::IVDep &) {
3196+ attachDirectiveToLoop (dir, &eval);
3197+ },
31813198 [&](const auto &) {}},
31823199 dir.u );
31833200 }
0 commit comments