[flang-commits] [flang] [FIR] add a fir.shape_extents operation (PR #199361)

via flang-commits flang-commits at lists.llvm.org
Mon Jun 8 09:19:05 PDT 2026


================
@@ -316,6 +323,36 @@ void FIRToMemRef::populateShape(SmallVectorImpl<Value> &vec,
   vec.append(shape.getExtents().begin(), shape.getExtents().end());
 }
 
+bool FIRToMemRef::materializeShapeExtents(
+    Value shapeVal, PatternRewriter &rewriter, Location loc,
+    SmallVectorImpl<Value> &shapeVec) const {
+  if (!shapeVal)
+    return false;
+
+  while (auto convertOp = shapeVal.getDefiningOp<fir::ConvertOp>())
+    shapeVal = convertOp.getOperand();
+
+  if (auto shapeOp = shapeVal.getDefiningOp<fir::ShapeOp>()) {
+    shapeVec.append(shapeOp.getExtents().begin(), shapeOp.getExtents().end());
+    return true;
+  }
+
+  if (auto extentsOp = shapeVal.getDefiningOp<fir::ShapeExtentsOp>()) {
----------------
jeanPerier wrote:

Ok, then this case should not be possible, a fir.shape should not be the result of a fir.shape_extent op, right?

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


More information about the flang-commits mailing list