[Bug fortran/57328] Missed optimization: Unable to vectorize Fortran min and max intrinsics

2013-05-21 Thread burnus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57328

Tobias Burnus burnus at gcc dot gnu.org changed:

   What|Removed |Added

 CC||burnus at gcc dot gnu.org

--- Comment #2 from Tobias Burnus burnus at gcc dot gnu.org ---
(In reply to Bud Davis from comment #1)
 The floating point number makes it special in some way.

My suspicion is that this is due to special handling for IEEE 754:2008, which
requires that
   MAX (NaN, x) = MAX (x, NaN) = x
   MIN (NaN, x) = MIN (x, NaN) = x


[Bug fortran/57328] Missed optimization: Unable to vectorize Fortran min and max intrinsics

2013-05-21 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57328

--- Comment #3 from Richard Biener rguenth at gcc dot gnu.org ---
Yes, you generally need -ffast-math here (or -ffinite-math-only at least).


[Bug fortran/57328] Missed optimization: Unable to vectorize Fortran min and max intrinsics

2013-05-21 Thread glisse at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57328

--- Comment #4 from Marc Glisse glisse at gcc dot gnu.org ---
(In reply to Richard Biener from comment #3)
 Yes, you generally need -ffast-math here (or -ffinite-math-only at least).

SSE2 has an unord comparison instruction (aka isnan) though, so vectorizing the
full version of min/max should still work, and be even more worth it than for
the finite-only min/max... Maybe a target issue?


[Bug fortran/57328] Missed optimization: Unable to vectorize Fortran min and max intrinsics

2013-05-21 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57328

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek jakub at gcc dot gnu.org ---
But vectorization reorders the loop iterations, thus say if some value is sNaN,
you'd get exceptions in different order.  So, I'm afraid without -ffast-math
you can vectorize this only if the user says that the order of iterations
doesn't matter (say using OpenMP 4.0 #pragma omp simd or Cilk+ #pragma simd).


[Bug fortran/57328] Missed optimization: Unable to vectorize Fortran min and max intrinsics

2013-05-21 Thread glisse at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57328

Marc Glisse glisse at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||missed-optimization

--- Comment #6 from Marc Glisse glisse at gcc dot gnu.org ---
(In reply to Jakub Jelinek from comment #5)
 But vectorization reorders the loop iterations, thus say if some value is
 sNaN, you'd get exceptions in different order.  So, I'm afraid without
 -ffast-math you can vectorize this only if the user says that the order of
 iterations doesn't matter (say using OpenMP 4.0 #pragma omp simd or Cilk+
 #pragma simd).

Ah, I was only thinking of quiet nans. -fno-signaling-nans should be enough
though, no? (I checked and it doesn't help, which makes sense since it is the
default) I think it is quite common to care about quiet nans but not use
signaling nans.


[Bug fortran/57328] Missed optimization: Unable to vectorize Fortran min and max intrinsics

2013-05-21 Thread spam.brian.taylor at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57328

--- Comment #7 from Brian Taylor spam.brian.taylor at gmail dot com ---
(In reply to Jakub Jelinek from comment #5)
 But vectorization reorders the loop iterations, thus say if some value is
 sNaN, you'd get exceptions in different order.  So, I'm afraid without
 -ffast-math you can vectorize this only if the user says that the order of
 iterations doesn't matter (say using OpenMP 4.0 #pragma omp simd or Cilk+
 #pragma simd).

I'm not sure this is actually a problem (or perhaps there is a another bug),
because as I noted in the PR replacing min or max with a functionally
equivalent sequence of if statements allows vectorization.


[Bug fortran/57328] Missed optimization: Unable to vectorize Fortran min and max intrinsics

2013-05-21 Thread bdavis at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57328

--- Comment #8 from Bud Davis bdavis at gcc dot gnu.org ---
The compiler generates code for min and max that checks if an argument is NaN. 
(floating point numbers only, of course).

This is different than the example you posted, as it would not give the correct
answer when an argument is NaN.


[Bug fortran/57328] Missed optimization: Unable to vectorize Fortran min and max intrinsics

2013-05-20 Thread bdavis at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57328

Bud Davis bdavis at gcc dot gnu.org changed:

   What|Removed |Added

 CC||bdavis at gcc dot gnu.org

--- Comment #1 from Bud Davis bdavis at gcc dot gnu.org ---
subroutine max_in_loop(rin, rout)
integer :: rin(1000), rout(1000), tmp
!real :: rin(1000), rout(1000), tmp
integer :: i

do i = 2, 1000
  tmp = min(rin(i-1), rin(i))
  rout(i) = tmp
end do

end subroutine

Is vectorized.
The floating point number makes it special in some way.

Looking in trans-intrinic.c , it is special.

   /* FIXME: When the IEEE_ARITHMETIC module is implemented, the call to
 __builtin_isnan might be made dependent on that module being loaded,
 to help performance of programs that don't rely on IEEE semantics.  */