The following idiom causes unnecessary runtime overhead: $ cat compare.f90 function foo(a,b,c,d) logical :: foo integer, intent(in):: a,b,c,d
foo = all((/ a, b, c /) /= d) end function foo $ gfortran -fdump-tree-optimized -O3 -S compare.f90 The *.optimized file shows <bb 2>: D.521 = (int4[0:] *) &A.2; D.522 = *a; (*D.521)[0] = D.522; D.523 = *b; (*D.521)[1] = D.523; D.524 = *c; (*D.521)[2] = D.524; D.516 = *d; The stores are unneeded, as the array itself could be eliminated. -- Summary: unnecessary stores for array constructor Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tkoenig at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33341