[flang-commits] [flang] [flang] add an optimization to remove fir.convert usage in FIRToMemRef (PR #187721)
Razvan Lupusoru via flang-commits
flang-commits at lists.llvm.org
Fri Mar 20 09:12:22 PDT 2026
================
@@ -1010,6 +1010,21 @@ void FIRToMemRef::rewriteStoreOp(fir::StoreOp store, PatternRewriter &rewriter,
Value value = store.getValue();
rewriter.setInsertionPointAfter(store);
+ // Small local optimization that avoids the round-trip:
+ // %25 = memref.load ... : memref<i32>
+ // %26 = fir.convert %25 : (i32) -> !fir.logical<4> // from load rewrite
+ // %27 = fir.convert %26 : (!fir.logical<4>) -> i32 // from store rewrite
+ // memref.store %27, ... : memref<i32>
+ // which would normalize the loaded value to 1 and break TRANSFER-like flows,
----------------
razvanlupusoru wrote:
I may not be familiar with the wording but TRANSFER written with all capitals made me think it was somehow a Fortran intrinsic. Also transfer suggests to me some value "moving" while casts are not necessarily transfer. Is this word use elsewhere in flang for this meaning?
https://github.com/llvm/llvm-project/pull/187721
More information about the flang-commits
mailing list