[flang-commits] [flang] [flang] restrict fir.convert lowering (PR #172117)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Fri Dec 12 17:20:40 PST 2025


================
@@ -816,6 +816,16 @@ struct ConvertOpConversion : public fir::FIROpConversion<fir::ConvertOp> {
                   mlir::ConversionPatternRewriter &rewriter) const override {
     auto fromFirTy = convert.getValue().getType();
     auto toFirTy = convert.getRes().getType();
+
+    // Let more specialized conversions (e.g. FIR to memref
+    // converters) handle fir.convert when either side is a memref. This
+    // avoids interfering with descriptor-based flows such as fir.box /
+    // fir.box_addr and keeps this pattern focused on value conversions.
+    if (mlir::isa<mlir::MemRefType>(fromFirTy) ||
+        mlir::isa<mlir::MemRefType>(toFirTy)) {
----------------
clementval wrote:

```suggestion
    if (mlir::isa<mlir::MemRefType>(fromFirTy, toFirTyoe) {
```

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


More information about the flang-commits mailing list