https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90608
--- Comment #8 from Mikael Morin <mikael at gcc dot gnu.org> --- Created attachment 56091 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56091&action=edit Rough patch Here is a rough patch to make the scalarizer support minloc calls. It regresses on minloc_1.f90 at least, but I haven't be able to pinpoint the problem in the original tree dump so far. The problem could be with the initialization of loop iteration variables. The existing code used for scalar minloc was versioning loops, that is it was using too loops in a row in some cases. With scalar minloc, the initialization of the loop variable could just be disabled in the second loop, but if there is more than one dimension as in the array case, this can't work. So the patch above initializes the loop variables conditionally on a "loop_break" boolean variable, which I hoped the optimizers would be able to remove. Unfortunately, this conditional initialization seems to confuse the optimizers a lot. Anyway, the patch is there; not sure how much I can pursue this further in the future.