[flang-commits] [flang] [flang] Inline hlfir.copy_in for trivial types (PR #138718)

Kajetan Puchalski via flang-commits flang-commits at lists.llvm.org
Fri Jun 6 05:03:21 PDT 2025


================
@@ -967,6 +969,15 @@ hlfir::LoopNest hlfir::genLoopNest(mlir::Location loc,
       auto ub = builder.createConvert(loc, indexType, extent);
       auto doLoop =
           builder.create<fir::DoLoopOp>(loc, one, ub, one, isUnordered);
+      if (!couldVectorize) {
+        mlir::LLVM::LoopVectorizeAttr va{mlir::LLVM::LoopVectorizeAttr::get(
+            builder.getContext(),
+            /*disable=*/builder.getBoolAttr(true), {}, {}, {}, {}, {}, {})};
+        mlir::LLVM::LoopAnnotationAttr la = mlir::LLVM::LoopAnnotationAttr::get(
+            builder.getContext(), {}, /*vectorize=*/va, {}, /*unroll*/ {},
+            /*unroll_and_jam*/ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {});
+        doLoop.setLoopAnnotationAttr(la);
+      }
----------------
mrkajetanp wrote:

There's [this](https://github.com/llvm/llvm-project/blob/7efb79b7053cec7cd712c0fede14e1478f353917/flang/test/Fir/vector-always.fir) test, it checks the `disable=false` case rather than `disable=true` but it does test the lowering. I can still add a copy like `vector-never.fir` if you'd like me to.

https://github.com/llvm/llvm-project/pull/138718


More information about the flang-commits mailing list