[all-commits] [llvm/llvm-project] 784836: [FIR] add a fir.shape_extents operation (#199361)
yebinchon via All-commits
all-commits at lists.llvm.org
Tue Jun 9 12:19:26 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 784836de471a74a45a4f4431974b7c3c588ffa81
https://github.com/llvm/llvm-project/commit/784836de471a74a45a4f4431974b7c3c588ffa81
Author: yebinchon <86588366+yebinchon at users.noreply.github.com>
Date: 2026-06-09 (Tue, 09 Jun 2026)
Changed paths:
M flang/include/flang/Optimizer/Dialect/FIROps.td
M flang/lib/Optimizer/CodeGen/CodeGen.cpp
M flang/lib/Optimizer/CodeGen/TypeConverter.cpp
M flang/lib/Optimizer/Dialect/FIROps.cpp
M flang/lib/Optimizer/Transforms/FIRToMemRef.cpp
M flang/test/Fir/convert-to-llvm-invalid.fir
A flang/test/Fir/shape-extents.mlir
A flang/test/Fir/shape-to-llvm.mlir
A flang/test/Transforms/FIRToMemRef/forwarded-shape.mlir
Log Message:
-----------
[FIR] add a fir.shape_extents operation (#199361)
Add fir.shape_extents op. This takes a !fir.shape<n> and unpacks it into
n integer SSA values (one per dimension, row-to-column order). This
supports lowering when extent values are needed but the defining
fir.shape is not visible.
FIRToMemRef now inserts fir.shape_extents when recovering extents from a
shape operand that is not a direct fir.shape / fir.shape_shift /
existing fir.shape_extents result (e.g. block arguments from
fir.select_case).
Also allow live fir.shape values at fir-to-llvm lowering: !fir.shape<n>
maps to an n-field i64 LLVM struct, and live fir.shape ops lower via
llvm.undef + llvm.insertvalue. fir.shape_extents lowers via
llvm.extractvalue (+ cast to index).
In the original path, cg-rewrite still fuses shape-bearing fir.embox /
fir.array_coor into fircg.* forms and shapes remain dead before LLVM
lowering. The new path is for forwarded shapes that survive past memref
lowering.
Tests: adds shape-extents.mlir (op + canonicalize) &
forwarded-shape.mlir (FIRToMemRef fir.shape_extents insertion)
updates convert-to-llvm-invalid.fir (live fir.shape is no longer an
invalid case).
---------
Co-authored-by: Yebin Chon <ychon at nvidia.com>
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