http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57328
Bug ID: 57328 Summary: Missed optimization: Unable to vectorize Fortran min and max intrinsics Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: spam.brian.taylor at gmail dot com Created attachment 30145 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30145&action=edit Test case for vectorization of loops containing max and if Use of the Fortran min or max intrinsic functions within a loop appears to prevent vectorization of the loop. Replacement of min or max with conditional assignment using if statements allows vectorization. A simple test case using max is attached. If compiled with "gfortran -O2 -msse2 -ftree-vectorize -ftree-vectorizer-verbose=1 -c max_vs_ifs_in_loop.F90", I get (with extraneous output snipped): ... max_vs_ifs_in_loop.F90:1: note: vectorized 0 loops in function. ... max_vs_ifs_in_loop.F90:17: note: LOOP VECTORIZED. ... gfortran should be able to vectorize loops containing min or max, using any number of arguments to these intrinsics, e.g. "tmp = max(r1, r2, r3, r4)". Compiler info: user@host $ gfortran --version GNU Fortran (GCC) 4.8.0 Copyright (C) 2013 Free Software Foundation, Inc. GNU Fortran comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of GNU Fortran under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING