[flang-commits] [flang] [flang] Enabled pulling of rebox into array_coor. (PR #199161)

Slava Zakharin via flang-commits flang-commits at lists.llvm.org
Tue May 26 10:02:27 PDT 2026


================
@@ -694,8 +695,18 @@ struct SimplifyArrayCoorOp : public mlir::OpRewritePattern<fir::ArrayCoorOp> {
       // ranks differ is out of scope.
       if (op.getSlice())
         return mlir::failure();
-      if (!boxedShape)
-        return mlir::failure();
+      if (!boxedShape) {
+        // fir.rebox with a rank-reducing slice often has no shape operand.
+        // Synthesize fir.shape from box_dims extents. Do not synthesize
+        // fir.shift: rebox descriptors already have (lb-1)*stride in base_addr
+        // and FIRToMemRef must not subtract lb again for rebox memrefs.
----------------
vzakhari wrote:

Thank you for the review, Jean! I fixed the comment.

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


More information about the flang-commits mailing list