[flang-commits] [flang] [llvm] [mlir] [Flang][OpenMP] Add nsw flags to OMPIRBuilder loop IV arithmetic (PR #214165)

Kaviya Rajendiran via flang-commits flang-commits at lists.llvm.org
Thu Aug 6 01:53:44 PDT 2026


kaviya2510 wrote:

> oes not seem to conflict with the existing implementation of nsw flags. On the other ha

The reason behind adding a module level attribute is:
- The loop IV arithmetic is not emitted during Fortran to MLIR lowering like regular do loops, instead it is emitted later by `OMPIRBuilder` inside the MLIR to LLVM translation pass, where the fortran LoweringOptions are out of scope.
- As `-fwrapv`/`-fno-wrapv` flag is a translation-unit-wide setting and it applies uniformly to every loop in the module. Attaching it to `omp.wsloop` or `omp.loop_nest` would mean every loop op carries an identical redundant annotation.
- Other compiler settings that need to reach `OMPIRBuilder` during translation is already a module attribute(e.g `omp.version, omp.is_target_device, omp.is_gpu, omp.flags, omp.requires`. So followed the similar approach inorder to be consistent with all other Openmp compilation settings.

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


More information about the flang-commits mailing list