[all-commits] [llvm/llvm-project] e1dd98: [flang][FIRToMemRef] fix stride calculation for co...

Susan Tan (ス-ザン タン) via All-commits all-commits at lists.llvm.org
Wed May 27 14:48:22 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e1dd984a809c9c7b8cc3731e3b8eeb8d01fbc8c1
      https://github.com/llvm/llvm-project/commit/e1dd984a809c9c7b8cc3731e3b8eeb8d01fbc8c1
  Author: Susan Tan (ス-ザン タン) <zujunt at nvidia.com>
  Date:   2026-05-27 (Wed, 27 May 2026)

  Changed paths:
    M flang/lib/Optimizer/Transforms/FIRToMemRef.cpp
    M flang/test/Transforms/FIRToMemRef/slice-projected.mlir

  Log Message:
  -----------
  [flang][FIRToMemRef] fix stride calculation for complex lowering (#200035)

**Summary**
When `fir.array_coor` targets a projected slice of a complex array (path
0 = real, 1 = imag), FIRToMemRef must not treat the result as a dense
memref.

**Bug:** The pass stopped after fir.convert to `memref<…×complex>` (or
static-shape fast path) and used default/dense strides. Loads/stores
then stepped by sizeof(complex) instead of sizeof(re)/sizeof(im).

**Fix:** For constant `%re/%im` on `complex<T>` storage:

`fir.convert` storage to `memref<…×2×T>` and index the component (0 or
1).
Read layout from `fir.box_dims` on the box (even if the memref shape is
static).
Set each memref stride to `box_dims_byte_stride / sizeof(T)`.

Advised by Cursor



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list