[flang-commits] [flang] [llvm] [flang] Support static-unit array slices in FIR LoopVersioning (PR #222723)

via flang-commits flang-commits at lists.llvm.org
Fri Sep 18 12:51:49 PDT 2026


================
@@ -285,6 +920,458 @@ static mlir::Value getIndex(fir::FirOpBuilder &builder, mlir::Operation *op,
   return mlir::arith::SubIOp::create(builder, coop.getLoc(), index, lb);
 }
 
+/// Convert one cloned slice operand to the index type before arithmetic.
+/// Preflight proved that this conversion preserves the effective index-domain
+/// bit pattern used by generic lowering.
+static mlir::Value materializeIndex(fir::FirOpBuilder &builder,
+                                    mlir::Location loc, mlir::Value value) {
+  mlir::Type indexType = builder.getIndexType();
+  if (value.getType() == indexType)
+    return value;
+  return builder.createConvert(loc, indexType, value);
+}
----------------
jeanPerier wrote:

`createConvert` is already creating nothing when the value has the requested type, I think you can skip this new helper to keep the code simpler.

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


More information about the flang-commits mailing list