This is all about non-rectangular loop nests in OpenMP. The attached patch depends on the obvious fix for https://gcc.gnu.org/PR108459, which is together with a nice testcase in Jakub's WIP patch attached to the PR; without, gfortran.dg/gomp/canonical-loop-1.f90 fails with an ICE (segfault). My patch fixes part of the Fortran issues found. Namely, it ensures that a "regular" non-rectangular loop nest actually works by passing the outer-loop-var, the multiplier and offset in a TREE_VEC to the middle end. It additionally avoids pointlessly creating a temporary variable for a VAR_DECL (main advantage: dump looks cleaner and avoids some dependency analysis) - and likewise for 'step' given that 'step' was evaluated before. There is an additional issue - not quite addressed in this patch: There are cases when a loop variable is replaced by another variable ('count') and then at the beginning of the loop body, the original variable gets the value from the count variable. Obviously, this no longer works with non-rectangular loop nests. The 'count' appears in two cases: (a) when the iteration step is not 1 or -1 and (b) if the iteration variable is a pointer (scalar with allocatable, pointer, optional argument or just a dummy argument; oddly, even if it has the value attribute). There is pending work to be done in this case, as mentioned in comment 6 and 8 of the PR. This patch adds some 'sorry' messages for them. I hope and think that I have not missed a case where 'count' is used which I did not catch, but I should have all or at least most. OK for mainline, once the other patch has been committed? Tobias PS: I still need to verify that everything is fine, once the other patch has been committed. A flaky mainboard on the laptop causes multiple random freezes per day, which makes testing + patch writing a bit harder. (At least the mainboard replacement is scheduled for tomorrow :-) ) ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955