llvm-project
e795686d - [FIRToMemRef] Fix wrong indexing for converted array_coor over sliced fir.embox (#207749)

Commit
5 days ago
[FIRToMemRef] Fix wrong indexing for converted array_coor over sliced fir.embox (#207749) FIRToMemRef::convertArrayCoorOp routes through getMemrefIndices, which only folds the first `rank` triples of sliceInfo.sliceVec into the memref indices (i.e. the array_coor's own slice); the embox's slice triples -- which sit at [rank*3 .. 2*rank*3-1] when both are present -- were dropped. Three consequences, three fixes here: 1. Non-collapsed embox slice lbs contribute (lb - 1) per Fortran dim to each memref index. Fold them in in memref order (reversed Fortran order) so the reinterpret_cast view lands at the right column. 2. The shapeVec-else stride path used shapeVec[0..rank-1] to build the outer strides. With both slices present, that's the box's (slice's) extents. Use shapeVec[rank..2*rank-1] instead -- the parent's extents -- so the outer stride is the parent's leading dim rather than the slice's own size. 3. Rank-reducing embox slices (undef ub/step triples) have no memref index position for their (lb - 1) shift. Fold the collapsed dim's (lb - 1) * parent_stride into the reinterpret_cast's flat offset and override the corresponding memref index entry to 0. --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Author
Parents
Loading