[flang-commits] [flang] [flang] Reset all extents to zero for empty hlfir.elemental loops. (PR #124867)
via flang-commits
flang-commits at lists.llvm.org
Wed Jan 29 01:18:13 PST 2025
================
@@ -1759,3 +1759,38 @@ fir::factory::deduceOptimalExtents(mlir::ValueRange extents1,
}
return extents;
}
+
+llvm::SmallVector<mlir::Value> fir::factory::updateRuntimeExtentsForEmptyArrays(
+ fir::FirOpBuilder &builder, mlir::Location loc, mlir::ValueRange extents) {
+ if (extents.size() <= 1)
+ return extents;
+
+ // Try to reduce the number of new zero constant operations.
+ // This just makes MLIR matching easier, if CSE is not run
+ // after this.
+ llvm::DenseMap<mlir::Type, mlir::Value> zeroesMap;
----------------
jeanPerier wrote:
Is it that common for extents values to have different types?
I am not against, but a single lazy zero mlir::Value for the extents (that will likely never be i1) would probably yield the same IR has the DenseMap in 99% of the cases.
https://github.com/llvm/llvm-project/pull/124867
More information about the flang-commits
mailing list