[flang-commits] [flang] [flang] Optimize assignments of multidimensional arrays (PR #146408)

Leandro Lupori via flang-commits flang-commits at lists.llvm.org
Thu Jul 3 07:51:42 PDT 2025


================
@@ -786,13 +797,59 @@ llvm::LogicalResult BroadcastAssignBufferization::matchAndRewrite(
   mlir::Value shape = hlfir::genShape(loc, builder, lhs);
   llvm::SmallVector<mlir::Value> extents =
       hlfir::getIndexExtents(loc, builder, shape);
-  hlfir::LoopNest loopNest =
-      hlfir::genLoopNest(loc, builder, extents, /*isUnordered=*/true,
-                         flangomp::shouldUseWorkshareLowering(assign));
-  builder.setInsertionPointToStart(loopNest.body);
-  auto arrayElement =
-      hlfir::getElementAt(loc, builder, lhs, loopNest.oneBasedIndices);
-  builder.create<hlfir::AssignOp>(loc, rhs, arrayElement);
+
+  bool isArrayRef =
+      mlir::isa<fir::SequenceType>(fir::unwrapRefType(lhs.getType()));
+  if (lhs.isSimplyContiguous() && extents.size() > 1 &&
----------------
luporl wrote:

Done. Removing the `isAllocatableArray` check also made it easier to support `!fir.box<!fir.array>`.
Now all boxed arrays are converted to `!fir.box<!fir.array<?x type>>`

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


More information about the flang-commits mailing list