jeanPerier b00cba5804
[flang] do not set nuw flag in CSHIFT bound arithmetic (#180520)
Fix https://github.com/llvm/llvm-project/issues/180374

I initially suspected an issue with some lower bound adjustment missing,
and indeed found an unrelated issue because gen1DSection was always
called with all-ones lower bounds because the genLowerbounds was called
on the result fir.shape.

But this is actually not relevant for the issue where this code path is
not exercised. The issue was `nuw` (no unsigned-wrap) was being set on
arithmetic inside the kernel generated for CSHIFT, but because this
arithmetic is dealing with user defined bounds, it may actually have to
deal with negative values (even if the offsets from the CSHIFT itself
are not negative).

This caused LLVM optimization to generate completely invalid code when
the lower bounds of CSHIFT input are zero or less.
2026-02-10 10:24:26 +01:00
..