[flang-commits] [flang] [flang] Fix optimization of array assignments after #146408 (PR #147371)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Wed Jul 9 06:25:00 PDT 2025
================
@@ -805,13 +805,12 @@ llvm::LogicalResult BroadcastAssignBufferization::matchAndRewrite(
shape, /*slice=*/mlir::Value{});
} else {
// Array references must have fixed shape, when used in assignments.
+ auto refTy = mlir::cast<fir::ReferenceType>(lhs.getType());
----------------
luporl wrote:
Now I understand @jeanPerier's comment.
Even after calling `hlfir::derefPointersAndAllocatables` the resulting type may still be a fir.heap/fir.ptr.
They can be converted to a fir.ref.
It seems `hlfir::derefPointersAndAllocatables` dereferences other pointer types, such as `!fir.ref<!fir.box<!fir.ptr<!fir.array...>>>`, generated from Fortran pointers, but not pointers directly to arrays, such as `!fir.ptr<!fir.array...>`, that may appear when `equivalence` is used.
I'll prepare a follow-up PR with this change.
https://github.com/llvm/llvm-project/pull/147371
More information about the flang-commits
mailing list