[flang-commits] [flang] [flang][docs] add design doc for inline runtime checks (PR #228502)

via flang-commits flang-commits at lists.llvm.org
Thu Oct 8 05:47:55 PDT 2026


jeanPerier wrote:

Thanks for the detailed review @vzakhari and @tblah!

> My AI reviewer wonders if this will also need explicit handling when inlining elemental operations. For example,

Great catch! Yes, placing the assert inside the fir.assert inside the fir.shape chains is not robust. It also prevents folding constant extents which may pessimize some FIR level analysis that would benefit from easily identifying constant extents.

Changed the rule for conformance checks: the assert guards the arrays being accessed, at the point where they are combined, and never the shapes. That means the operands that don't provide the iteration space of an elemental operation, and both sides of an assignment. Shapes stay foldable, and constant extents still reach loop bounds.

This implies that InlineHLFIRElemental will need to understand the fir.assert in between and hlfir.elemental results and its hlfir.apply user and moves them to guard either the index provided to the inlined body, or the values used in the inlined body that do not belong to the body (typically the addresses of the arrays). Will probably refine this while implementing.

The latest update of the patch addresses your comments and changes the strategy of how fir.assert will be used for conformance checks. The operation itself is not changed.

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


More information about the flang-commits mailing list