http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50374
--- Comment #17 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-09-21 16:57:08 UTC --- Seems my reduction patterns just give some extreme's index, but not necessarily the first or last extreme's index. It was just narrowing down the index vector together with the comparison vector the same way, picking the values the comparison picked. Seems Ira's patch does the right thing, in particular, finding the minimum resp. maximum (then at least on i?86 I'll need to broadcast that value to all vector members as the shifts have zero filled instead of kept the upper bits as is), then compare that to the original comparison vector (i.e. get mask where the minimum values were), mask the index vector with that mask, find the minimum (for *FIRST_LOC*) resp. maximum (for *LAST_LOC*) in the index vector (for FIRST_LOC ~mask actually needs to be ored in). I'll fix that up tomorrow. Now, does the generic vectorizer code ensure that the biv has the right properties (doesn't wrap in the loop and is strictly increasing)? And, if it is signed that it is never negative?