[1/2] libgfortran: Remove early return if extent is zero [PR112371]

Message ID 20231106114325.828968-2-mikael@gcc.gnu.org
State Accepted
Headers
Series libgfortran: empty array fixes [PR112371] |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Mikael Morin Nov. 6, 2023, 11:43 a.m. UTC
  Remove the early return present in function templates for transformational
functions doing a (masked) reduction of an array along a dimension.
This early return, which triggered if the extent in the reduction dimension
was zero, was wrong because even if the reduction operation degenerates to
a constant value in that case, one has to loop anyway along the other
dimensions to initialize every element of the resulting array with that
constant value.

The offending piece of code was present in several places, and this removes
them all.  Namely, the impacted m4 files are ifunction.m4 for regular
functions and types, ifunction-s.m4 for character minloc and maxloc, and
ifunction-s2.m4 for character minval and maxval.

	PR fortran/112371

libgfortran/ChangeLog:

	* m4/ifunction.m4 (START_MASKED_ARRAY_FUNCTION): Remove early return if
	extent is zero.
	* m4/ifunction-s.m4 (START_MASKED_ARRAY_FUNCTION): Ditto.
	* m4/ifunction-s2.m4 (START_MASKED_ARRAY_FUNCTION): Ditto.
	* generated/iall_i1.c: Regenerate.
	* generated/iall_i16.c: Regenerate.
	* generated/iall_i2.c: Regenerate.
	* generated/iall_i4.c: Regenerate.
	* generated/iall_i8.c: Regenerate.
	* generated/iany_i1.c: Regenerate.
	* generated/iany_i16.c: Regenerate.
	* generated/iany_i2.c: Regenerate.
	* generated/iany_i4.c: Regenerate.
	* generated/iany_i8.c: Regenerate.
	* generated/iparity_i1.c: Regenerate.
	* generated/iparity_i16.c: Regenerate.
	* generated/iparity_i2.c: Regenerate.
	* generated/iparity_i4.c: Regenerate.
	* generated/iparity_i8.c: Regenerate.
	* generated/maxloc1_16_i1.c: Regenerate.
	* generated/maxloc1_16_i16.c: Regenerate.
	* generated/maxloc1_16_i2.c: Regenerate.
	* generated/maxloc1_16_i4.c: Regenerate.
	* generated/maxloc1_16_i8.c: Regenerate.
	* generated/maxloc1_16_r10.c: Regenerate.
	* generated/maxloc1_16_r16.c: Regenerate.
	* generated/maxloc1_16_r17.c: Regenerate.
	* generated/maxloc1_16_r4.c: Regenerate.
	* generated/maxloc1_16_r8.c: Regenerate.
	* generated/maxloc1_16_s1.c: Regenerate.
	* generated/maxloc1_16_s4.c: Regenerate.
	* generated/maxloc1_4_i1.c: Regenerate.
	* generated/maxloc1_4_i16.c: Regenerate.
	* generated/maxloc1_4_i2.c: Regenerate.
	* generated/maxloc1_4_i4.c: Regenerate.
	* generated/maxloc1_4_i8.c: Regenerate.
	* generated/maxloc1_4_r10.c: Regenerate.
	* generated/maxloc1_4_r16.c: Regenerate.
	* generated/maxloc1_4_r17.c: Regenerate.
	* generated/maxloc1_4_r4.c: Regenerate.
	* generated/maxloc1_4_r8.c: Regenerate.
	* generated/maxloc1_4_s1.c: Regenerate.
	* generated/maxloc1_4_s4.c: Regenerate.
	* generated/maxloc1_8_i1.c: Regenerate.
	* generated/maxloc1_8_i16.c: Regenerate.
	* generated/maxloc1_8_i2.c: Regenerate.
	* generated/maxloc1_8_i4.c: Regenerate.
	* generated/maxloc1_8_i8.c: Regenerate.
	* generated/maxloc1_8_r10.c: Regenerate.
	* generated/maxloc1_8_r16.c: Regenerate.
	* generated/maxloc1_8_r17.c: Regenerate.
	* generated/maxloc1_8_r4.c: Regenerate.
	* generated/maxloc1_8_r8.c: Regenerate.
	* generated/maxloc1_8_s1.c: Regenerate.
	* generated/maxloc1_8_s4.c: Regenerate.
	* generated/maxval1_s1.c: Regenerate.
	* generated/maxval1_s4.c: Regenerate.
	* generated/maxval_i1.c: Regenerate.
	* generated/maxval_i16.c: Regenerate.
	* generated/maxval_i2.c: Regenerate.
	* generated/maxval_i4.c: Regenerate.
	* generated/maxval_i8.c: Regenerate.
	* generated/maxval_r10.c: Regenerate.
	* generated/maxval_r16.c: Regenerate.
	* generated/maxval_r17.c: Regenerate.
	* generated/maxval_r4.c: Regenerate.
	* generated/maxval_r8.c: Regenerate.
	* generated/minloc1_16_i1.c: Regenerate.
	* generated/minloc1_16_i16.c: Regenerate.
	* generated/minloc1_16_i2.c: Regenerate.
	* generated/minloc1_16_i4.c: Regenerate.
	* generated/minloc1_16_i8.c: Regenerate.
	* generated/minloc1_16_r10.c: Regenerate.
	* generated/minloc1_16_r16.c: Regenerate.
	* generated/minloc1_16_r17.c: Regenerate.
	* generated/minloc1_16_r4.c: Regenerate.
	* generated/minloc1_16_r8.c: Regenerate.
	* generated/minloc1_16_s1.c: Regenerate.
	* generated/minloc1_16_s4.c: Regenerate.
	* generated/minloc1_4_i1.c: Regenerate.
	* generated/minloc1_4_i16.c: Regenerate.
	* generated/minloc1_4_i2.c: Regenerate.
	* generated/minloc1_4_i4.c: Regenerate.
	* generated/minloc1_4_i8.c: Regenerate.
	* generated/minloc1_4_r10.c: Regenerate.
	* generated/minloc1_4_r16.c: Regenerate.
	* generated/minloc1_4_r17.c: Regenerate.
	* generated/minloc1_4_r4.c: Regenerate.
	* generated/minloc1_4_r8.c: Regenerate.
	* generated/minloc1_4_s1.c: Regenerate.
	* generated/minloc1_4_s4.c: Regenerate.
	* generated/minloc1_8_i1.c: Regenerate.
	* generated/minloc1_8_i16.c: Regenerate.
	* generated/minloc1_8_i2.c: Regenerate.
	* generated/minloc1_8_i4.c: Regenerate.
	* generated/minloc1_8_i8.c: Regenerate.
	* generated/minloc1_8_r10.c: Regenerate.
	* generated/minloc1_8_r16.c: Regenerate.
	* generated/minloc1_8_r17.c: Regenerate.
	* generated/minloc1_8_r4.c: Regenerate.
	* generated/minloc1_8_r8.c: Regenerate.
	* generated/minloc1_8_s1.c: Regenerate.
	* generated/minloc1_8_s4.c: Regenerate.
	* generated/minval1_s1.c: Regenerate.
	* generated/minval1_s4.c: Regenerate.
	* generated/minval_i1.c: Regenerate.
	* generated/minval_i16.c: Regenerate.
	* generated/minval_i2.c: Regenerate.
	* generated/minval_i4.c: Regenerate.
	* generated/minval_i8.c: Regenerate.
	* generated/minval_r10.c: Regenerate.
	* generated/minval_r16.c: Regenerate.
	* generated/minval_r17.c: Regenerate.
	* generated/minval_r4.c: Regenerate.
	* generated/minval_r8.c: Regenerate.
	* generated/product_c10.c: Regenerate.
	* generated/product_c16.c: Regenerate.
	* generated/product_c17.c: Regenerate.
	* generated/product_c4.c: Regenerate.
	* generated/product_c8.c: Regenerate.
	* generated/product_i1.c: Regenerate.
	* generated/product_i16.c: Regenerate.
	* generated/product_i2.c: Regenerate.
	* generated/product_i4.c: Regenerate.
	* generated/product_i8.c: Regenerate.
	* generated/product_r10.c: Regenerate.
	* generated/product_r16.c: Regenerate.
	* generated/product_r17.c: Regenerate.
	* generated/product_r4.c: Regenerate.
	* generated/product_r8.c: Regenerate.
	* generated/sum_c10.c: Regenerate.
	* generated/sum_c16.c: Regenerate.
	* generated/sum_c17.c: Regenerate.
	* generated/sum_c4.c: Regenerate.
	* generated/sum_c8.c: Regenerate.
	* generated/sum_i1.c: Regenerate.
	* generated/sum_i16.c: Regenerate.
	* generated/sum_i2.c: Regenerate.
	* generated/sum_i4.c: Regenerate.
	* generated/sum_i8.c: Regenerate.
	* generated/sum_r10.c: Regenerate.
	* generated/sum_r16.c: Regenerate.
	* generated/sum_r17.c: Regenerate.
	* generated/sum_r4.c: Regenerate.
	* generated/sum_r8.c: Regenerate.

gcc/testsuite/ChangeLog:

	* gfortran.dg/bound_10.f90: New test.
---
 gcc/testsuite/gfortran.dg/bound_10.f90 | 207 +++++++++++++++++++++++++
 libgfortran/generated/iall_i1.c        |   2 -
 libgfortran/generated/iall_i16.c       |   2 -
 libgfortran/generated/iall_i2.c        |   2 -
 libgfortran/generated/iall_i4.c        |   2 -
 libgfortran/generated/iall_i8.c        |   2 -
 libgfortran/generated/iany_i1.c        |   2 -
 libgfortran/generated/iany_i16.c       |   2 -
 libgfortran/generated/iany_i2.c        |   2 -
 libgfortran/generated/iany_i4.c        |   2 -
 libgfortran/generated/iany_i8.c        |   2 -
 libgfortran/generated/iparity_i1.c     |   2 -
 libgfortran/generated/iparity_i16.c    |   2 -
 libgfortran/generated/iparity_i2.c     |   2 -
 libgfortran/generated/iparity_i4.c     |   2 -
 libgfortran/generated/iparity_i8.c     |   2 -
 libgfortran/generated/maxloc1_16_i1.c  |   2 -
 libgfortran/generated/maxloc1_16_i16.c |   2 -
 libgfortran/generated/maxloc1_16_i2.c  |   2 -
 libgfortran/generated/maxloc1_16_i4.c  |   2 -
 libgfortran/generated/maxloc1_16_i8.c  |   2 -
 libgfortran/generated/maxloc1_16_r10.c |   2 -
 libgfortran/generated/maxloc1_16_r16.c |   2 -
 libgfortran/generated/maxloc1_16_r17.c |   2 -
 libgfortran/generated/maxloc1_16_r4.c  |   2 -
 libgfortran/generated/maxloc1_16_r8.c  |   2 -
 libgfortran/generated/maxloc1_16_s1.c  |   2 -
 libgfortran/generated/maxloc1_16_s4.c  |   2 -
 libgfortran/generated/maxloc1_4_i1.c   |   2 -
 libgfortran/generated/maxloc1_4_i16.c  |   2 -
 libgfortran/generated/maxloc1_4_i2.c   |   2 -
 libgfortran/generated/maxloc1_4_i4.c   |   2 -
 libgfortran/generated/maxloc1_4_i8.c   |   2 -
 libgfortran/generated/maxloc1_4_r10.c  |   2 -
 libgfortran/generated/maxloc1_4_r16.c  |   2 -
 libgfortran/generated/maxloc1_4_r17.c  |   2 -
 libgfortran/generated/maxloc1_4_r4.c   |   2 -
 libgfortran/generated/maxloc1_4_r8.c   |   2 -
 libgfortran/generated/maxloc1_4_s1.c   |   2 -
 libgfortran/generated/maxloc1_4_s4.c   |   2 -
 libgfortran/generated/maxloc1_8_i1.c   |   2 -
 libgfortran/generated/maxloc1_8_i16.c  |   2 -
 libgfortran/generated/maxloc1_8_i2.c   |   2 -
 libgfortran/generated/maxloc1_8_i4.c   |   2 -
 libgfortran/generated/maxloc1_8_i8.c   |   2 -
 libgfortran/generated/maxloc1_8_r10.c  |   2 -
 libgfortran/generated/maxloc1_8_r16.c  |   2 -
 libgfortran/generated/maxloc1_8_r17.c  |   2 -
 libgfortran/generated/maxloc1_8_r4.c   |   2 -
 libgfortran/generated/maxloc1_8_r8.c   |   2 -
 libgfortran/generated/maxloc1_8_s1.c   |   2 -
 libgfortran/generated/maxloc1_8_s4.c   |   2 -
 libgfortran/generated/maxval1_s1.c     |   2 -
 libgfortran/generated/maxval1_s4.c     |   2 -
 libgfortran/generated/maxval_i1.c      |   2 -
 libgfortran/generated/maxval_i16.c     |   2 -
 libgfortran/generated/maxval_i2.c      |   2 -
 libgfortran/generated/maxval_i4.c      |   2 -
 libgfortran/generated/maxval_i8.c      |   2 -
 libgfortran/generated/maxval_r10.c     |   2 -
 libgfortran/generated/maxval_r16.c     |   2 -
 libgfortran/generated/maxval_r17.c     |   2 -
 libgfortran/generated/maxval_r4.c      |   2 -
 libgfortran/generated/maxval_r8.c      |   2 -
 libgfortran/generated/minloc1_16_i1.c  |   2 -
 libgfortran/generated/minloc1_16_i16.c |   2 -
 libgfortran/generated/minloc1_16_i2.c  |   2 -
 libgfortran/generated/minloc1_16_i4.c  |   2 -
 libgfortran/generated/minloc1_16_i8.c  |   2 -
 libgfortran/generated/minloc1_16_r10.c |   2 -
 libgfortran/generated/minloc1_16_r16.c |   2 -
 libgfortran/generated/minloc1_16_r17.c |   2 -
 libgfortran/generated/minloc1_16_r4.c  |   2 -
 libgfortran/generated/minloc1_16_r8.c  |   2 -
 libgfortran/generated/minloc1_16_s1.c  |   2 -
 libgfortran/generated/minloc1_16_s4.c  |   2 -
 libgfortran/generated/minloc1_4_i1.c   |   2 -
 libgfortran/generated/minloc1_4_i16.c  |   2 -
 libgfortran/generated/minloc1_4_i2.c   |   2 -
 libgfortran/generated/minloc1_4_i4.c   |   2 -
 libgfortran/generated/minloc1_4_i8.c   |   2 -
 libgfortran/generated/minloc1_4_r10.c  |   2 -
 libgfortran/generated/minloc1_4_r16.c  |   2 -
 libgfortran/generated/minloc1_4_r17.c  |   2 -
 libgfortran/generated/minloc1_4_r4.c   |   2 -
 libgfortran/generated/minloc1_4_r8.c   |   2 -
 libgfortran/generated/minloc1_4_s1.c   |   2 -
 libgfortran/generated/minloc1_4_s4.c   |   2 -
 libgfortran/generated/minloc1_8_i1.c   |   2 -
 libgfortran/generated/minloc1_8_i16.c  |   2 -
 libgfortran/generated/minloc1_8_i2.c   |   2 -
 libgfortran/generated/minloc1_8_i4.c   |   2 -
 libgfortran/generated/minloc1_8_i8.c   |   2 -
 libgfortran/generated/minloc1_8_r10.c  |   2 -
 libgfortran/generated/minloc1_8_r16.c  |   2 -
 libgfortran/generated/minloc1_8_r17.c  |   2 -
 libgfortran/generated/minloc1_8_r4.c   |   2 -
 libgfortran/generated/minloc1_8_r8.c   |   2 -
 libgfortran/generated/minloc1_8_s1.c   |   2 -
 libgfortran/generated/minloc1_8_s4.c   |   2 -
 libgfortran/generated/minval1_s1.c     |   2 -
 libgfortran/generated/minval1_s4.c     |   2 -
 libgfortran/generated/minval_i1.c      |   2 -
 libgfortran/generated/minval_i16.c     |   2 -
 libgfortran/generated/minval_i2.c      |   2 -
 libgfortran/generated/minval_i4.c      |   2 -
 libgfortran/generated/minval_i8.c      |   2 -
 libgfortran/generated/minval_r10.c     |   2 -
 libgfortran/generated/minval_r16.c     |   2 -
 libgfortran/generated/minval_r17.c     |   2 -
 libgfortran/generated/minval_r4.c      |   2 -
 libgfortran/generated/minval_r8.c      |   2 -
 libgfortran/generated/product_c10.c    |   2 -
 libgfortran/generated/product_c16.c    |   2 -
 libgfortran/generated/product_c17.c    |   2 -
 libgfortran/generated/product_c4.c     |   2 -
 libgfortran/generated/product_c8.c     |   2 -
 libgfortran/generated/product_i1.c     |   2 -
 libgfortran/generated/product_i16.c    |   2 -
 libgfortran/generated/product_i2.c     |   2 -
 libgfortran/generated/product_i4.c     |   2 -
 libgfortran/generated/product_i8.c     |   2 -
 libgfortran/generated/product_r10.c    |   2 -
 libgfortran/generated/product_r16.c    |   2 -
 libgfortran/generated/product_r17.c    |   2 -
 libgfortran/generated/product_r4.c     |   2 -
 libgfortran/generated/product_r8.c     |   2 -
 libgfortran/generated/sum_c10.c        |   2 -
 libgfortran/generated/sum_c16.c        |   2 -
 libgfortran/generated/sum_c17.c        |   2 -
 libgfortran/generated/sum_c4.c         |   2 -
 libgfortran/generated/sum_c8.c         |   2 -
 libgfortran/generated/sum_i1.c         |   2 -
 libgfortran/generated/sum_i16.c        |   2 -
 libgfortran/generated/sum_i2.c         |   2 -
 libgfortran/generated/sum_i4.c         |   2 -
 libgfortran/generated/sum_i8.c         |   2 -
 libgfortran/generated/sum_r10.c        |   2 -
 libgfortran/generated/sum_r16.c        |   2 -
 libgfortran/generated/sum_r17.c        |   2 -
 libgfortran/generated/sum_r4.c         |   2 -
 libgfortran/generated/sum_r8.c         |   2 -
 libgfortran/m4/ifunction-s.m4          |   2 -
 libgfortran/m4/ifunction-s2.m4         |   2 -
 libgfortran/m4/ifunction.m4            |   2 -
 145 files changed, 207 insertions(+), 288 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/bound_10.f90
  

Comments

Harald Anlauf Nov. 6, 2023, 6:12 p.m. UTC | #1
Hi Mikael,

Am 06.11.23 um 12:43 schrieb Mikael Morin:
> Remove the early return present in function templates for transformational
> functions doing a (masked) reduction of an array along a dimension.
> This early return, which triggered if the extent in the reduction dimension
> was zero, was wrong because even if the reduction operation degenerates to
> a constant value in that case, one has to loop anyway along the other
> dimensions to initialize every element of the resulting array with that
> constant value.
>
> The offending piece of code was present in several places, and this removes
> them all.  Namely, the impacted m4 files are ifunction.m4 for regular
> functions and types, ifunction-s.m4 for character minloc and maxloc, and
> ifunction-s2.m4 for character minval and maxval.

I wonder if the correct fix would be to replace (instead of deleting)

> diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4
> index c64217ec5db..480649cf691 100644
> --- a/libgfortran/m4/ifunction.m4
> +++ b/libgfortran/m4/ifunction.m4
> @@ -232,8 +232,6 @@ m'name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray,
>       }
>
>     len = GFC_DESCRIPTOR_EXTENT(array,dim);
> -  if (len <= 0)
> -    return;
>
>     mbase = mask->base_addr;
>

by the following:

   if (len < 0)
     len = 0;

See ifunction.m4, lines 56ff, which check if the result of

   len = GFC_DESCRIPTOR_EXTENT(array,dim);

is negative.  I haven't tried to create a testcase, though.

Similarly for the other templates.

Thanks,
Harald
  
Mikael Morin Nov. 6, 2023, 6:57 p.m. UTC | #2
Le 06/11/2023 à 19:12, Harald Anlauf a écrit :
> Hi Mikael,
> 
> Am 06.11.23 um 12:43 schrieb Mikael Morin:
>> Remove the early return present in function templates for 
>> transformational
>> functions doing a (masked) reduction of an array along a dimension.
>> This early return, which triggered if the extent in the reduction 
>> dimension
>> was zero, was wrong because even if the reduction operation 
>> degenerates to
>> a constant value in that case, one has to loop anyway along the other
>> dimensions to initialize every element of the resulting array with that
>> constant value.
>>
>> The offending piece of code was present in several places, and this 
>> removes
>> them all.  Namely, the impacted m4 files are ifunction.m4 for regular
>> functions and types, ifunction-s.m4 for character minloc and maxloc, and
>> ifunction-s2.m4 for character minval and maxval.
> 
> I wonder if the correct fix would be to replace (instead of deleting)
> 
>> diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4
>> index c64217ec5db..480649cf691 100644
>> --- a/libgfortran/m4/ifunction.m4
>> +++ b/libgfortran/m4/ifunction.m4
>> @@ -232,8 +232,6 @@ m'name`'rtype_qual`_'atype_code` ('rtype` * const 
>> restrict retarray,
>>       }
>>
>>     len = GFC_DESCRIPTOR_EXTENT(array,dim);
>> -  if (len <= 0)
>> -    return;
>>
>>     mbase = mask->base_addr;
>>
> 
> by the following:
> 
>    if (len < 0)
>      len = 0;
> 
> See ifunction.m4, lines 56ff, which check if the result of
> 
>    len = GFC_DESCRIPTOR_EXTENT(array,dim);
> 
> is negative.  I haven't tried to create a testcase, though.
> 
> Similarly for the other templates.
> 

Yes, you're right.  I think I won't try to create a testcase and will 
just pick your suggestion which seems safer.
  

Patch

diff --git a/gcc/testsuite/gfortran.dg/bound_10.f90 b/gcc/testsuite/gfortran.dg/bound_10.f90
new file mode 100644
index 00000000000..cbe065cf2b6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/bound_10.f90
@@ -0,0 +1,207 @@ 
+! { dg-do run }
+!
+! PR fortran/112371
+! The library used to not set the bounds and content of the resulting array
+! of a reduction function if the input array had zero extent along the
+! reduction dimension.
+
+program p
+  implicit none
+  call check_iall
+  call check_iany
+  call check_iparity
+  call check_minloc_int
+  call check_minloc_char
+  call check_maxloc_real
+  call check_maxloc_char
+  call check_minval_int
+  call check_minval_char
+  call check_maxval_real
+  call check_maxval_char
+  call check_sum
+  call check_product
+contains
+  subroutine check_iall
+    integer :: a(3,0,2)
+    logical(kind=1) :: m(3,0,2)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ integer:: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 2
+    r = iall(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 11
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 12
+    if (any(shape(r) /= (/ 3, 2 /))) stop 13
+    if (any(r /= int(z'FFFFFFFF'))) stop 14
+  end subroutine
+  subroutine check_iany
+    integer(kind=8) :: a(2,3,0)
+    logical(kind=1) :: m(2,3,0)
+    integer :: i
+    integer(kind=8), allocatable :: r(:,:)
+    a = reshape((/ integer(kind=8):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 3
+    r = iany(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 21
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 22
+    if (any(shape(r) /= (/ 2, 3 /))) stop 23
+    if (any(r /= 0)) stop 24
+  end subroutine
+  subroutine check_iparity
+    integer(kind=2) :: a(0,2,3)
+    logical(kind=1) :: m(0,2,3)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ integer(kind=2):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 1
+    r = iparity(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 31
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 32
+    if (any(shape(r) /= (/ 2, 3 /))) stop 33
+    if (any(r /= 0)) stop 34
+  end subroutine
+  subroutine check_minloc_int
+    integer :: a(3,0,2)
+    logical(kind=1) :: m(3,0,2)
+    integer :: i, j
+    integer, allocatable :: r(:,:)
+    a = reshape((/ integer:: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 2
+    r = minloc(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 41
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 42
+    if (any(shape(r) /= (/ 3, 2 /))) stop 43
+    if (any(r /= 0)) stop 44
+  end subroutine
+  subroutine check_minloc_char
+    character :: a(2,3,0)
+    logical(kind=1) :: m(2,3,0)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ character:: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 3
+    r = minloc(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 51
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 52
+    if (any(shape(r) /= (/ 2, 3 /))) stop 53
+    if (any(r /= 0)) stop 54
+  end subroutine
+  subroutine check_maxloc_real
+    real :: a(0,2,3)
+    logical(kind=1) :: m(0,2,3)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ real:: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 1
+    r = maxloc(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 61
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 62
+    if (any(shape(r) /= (/ 2, 3 /))) stop 63
+    if (any(r /= 0)) stop 64
+  end subroutine
+  subroutine check_maxloc_char
+    character(len=2) :: a(3,0,2)
+    logical(kind=1) :: m(3,0,2)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ character(len=2):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 2
+    r = maxloc(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 71
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 72
+    if (any(shape(r) /= (/ 3, 2 /))) stop 73
+    if (any(r /= 0)) stop 74
+  end subroutine
+  subroutine check_minval_int
+    integer(kind=2) :: a(3,2,0)
+    logical(kind=1) :: m(3,2,0)
+    integer :: i, j
+    integer, allocatable :: r(:,:)
+    a = reshape((/ integer(kind=2):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 3
+    r = minval(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 81
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 82
+    if (any(shape(r) /= (/ 3, 2 /))) stop 83
+    if (any(r /= huge(1_2))) stop 84
+  end subroutine
+  subroutine check_minval_char
+    character(kind=4) :: a(0,3,2)
+    logical(kind=1) :: m(0,3,2)
+    integer :: i
+    character(kind=4), allocatable :: r(:,:)
+    a = reshape((/ character(kind=4):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 1
+    r = minval(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 91
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 92
+    if (any(shape(r) /= (/ 3, 2 /))) stop 93
+    if (any(r /= char(int(z'FFFFFFFF', kind=8), kind=4))) stop 94
+  end subroutine
+  subroutine check_maxval_real
+    real(kind=8) :: a(0,2,3)
+    logical(kind=1) :: m(0,2,3)
+    integer :: i
+    real(kind=8), allocatable :: r(:,:)
+    a = reshape((/ real(kind=8):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 1
+    r = maxval(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 101
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 102
+    if (any(shape(r) /= (/ 2, 3 /))) stop 103
+    if (any(r /= -huge(1._8))) stop 104
+  end subroutine
+  subroutine check_maxval_char
+    character(kind=4,len=2) :: a(3,0,2), e
+    logical(kind=1) :: m(3,0,2)
+    integer :: i
+    character(len=2,kind=4), allocatable :: r(:,:)
+    a = reshape((/ character(kind=4,len=2):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 2
+    r = maxval(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 111
+    if (any(ubound(r) /= (/ 3, 2 /))) stop 112
+    if (any(shape(r) /= (/ 3, 2 /))) stop 113
+    e = repeat(char(0, kind=4), len(a))
+    if (any(r /= e)) stop 114
+  end subroutine
+  subroutine check_sum
+    integer(kind=1) :: a(2,3,0)
+    logical(kind=1) :: m(2,3,0)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ integer:: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 3
+    r = sum(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 121
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 122
+    if (any(shape(r) /= (/ 2, 3 /))) stop 123
+    if (any(r /= 0)) stop 124
+  end subroutine
+  subroutine check_product
+    real(kind=8) :: a(0,2,3)
+    logical(kind=1) :: m(0,2,3)
+    integer :: i
+    integer, allocatable :: r(:,:)
+    a = reshape((/ real(kind=8):: /), shape(a))
+    m = reshape((/ logical(kind=1):: /), shape(m))
+    i = 1
+    r = product(a, dim=i, mask=m)
+    if (any(lbound(r) /= 1)) stop 131
+    if (any(ubound(r) /= (/ 2, 3 /))) stop 132
+    if (any(shape(r) /= (/ 2, 3 /))) stop 133
+    if (any(r /= 1.0_8)) stop 134
+  end subroutine
+end program
diff --git a/libgfortran/generated/iall_i1.c b/libgfortran/generated/iall_i1.c
index 4af96269308..44ccbce270a 100644
--- a/libgfortran/generated/iall_i1.c
+++ b/libgfortran/generated/iall_i1.c
@@ -242,8 +242,6 @@  miall_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iall_i16.c b/libgfortran/generated/iall_i16.c
index e678d06d1b8..98deeed4a4a 100644
--- a/libgfortran/generated/iall_i16.c
+++ b/libgfortran/generated/iall_i16.c
@@ -242,8 +242,6 @@  miall_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iall_i2.c b/libgfortran/generated/iall_i2.c
index fbe52663f16..9ed8079c2ef 100644
--- a/libgfortran/generated/iall_i2.c
+++ b/libgfortran/generated/iall_i2.c
@@ -242,8 +242,6 @@  miall_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iall_i4.c b/libgfortran/generated/iall_i4.c
index 3d6b6deba3d..6e5c4a80ae5 100644
--- a/libgfortran/generated/iall_i4.c
+++ b/libgfortran/generated/iall_i4.c
@@ -242,8 +242,6 @@  miall_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iall_i8.c b/libgfortran/generated/iall_i8.c
index 072f6837029..7eddce7f211 100644
--- a/libgfortran/generated/iall_i8.c
+++ b/libgfortran/generated/iall_i8.c
@@ -242,8 +242,6 @@  miall_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iany_i1.c b/libgfortran/generated/iany_i1.c
index 6f03df6efd2..43ec43ee89b 100644
--- a/libgfortran/generated/iany_i1.c
+++ b/libgfortran/generated/iany_i1.c
@@ -242,8 +242,6 @@  miany_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iany_i16.c b/libgfortran/generated/iany_i16.c
index 72a7add660b..d5a30607d99 100644
--- a/libgfortran/generated/iany_i16.c
+++ b/libgfortran/generated/iany_i16.c
@@ -242,8 +242,6 @@  miany_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iany_i2.c b/libgfortran/generated/iany_i2.c
index 26858b42916..4086bd1dbd2 100644
--- a/libgfortran/generated/iany_i2.c
+++ b/libgfortran/generated/iany_i2.c
@@ -242,8 +242,6 @@  miany_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iany_i4.c b/libgfortran/generated/iany_i4.c
index ca315d1223c..7076f0c4c3b 100644
--- a/libgfortran/generated/iany_i4.c
+++ b/libgfortran/generated/iany_i4.c
@@ -242,8 +242,6 @@  miany_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iany_i8.c b/libgfortran/generated/iany_i8.c
index dc9081e5149..a648fe8c45f 100644
--- a/libgfortran/generated/iany_i8.c
+++ b/libgfortran/generated/iany_i8.c
@@ -242,8 +242,6 @@  miany_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iparity_i1.c b/libgfortran/generated/iparity_i1.c
index cfb2e481831..26144505efe 100644
--- a/libgfortran/generated/iparity_i1.c
+++ b/libgfortran/generated/iparity_i1.c
@@ -242,8 +242,6 @@  miparity_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iparity_i16.c b/libgfortran/generated/iparity_i16.c
index 3b1f3232327..165a1a81418 100644
--- a/libgfortran/generated/iparity_i16.c
+++ b/libgfortran/generated/iparity_i16.c
@@ -242,8 +242,6 @@  miparity_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iparity_i2.c b/libgfortran/generated/iparity_i2.c
index 60575bdcb15..e2ba668a562 100644
--- a/libgfortran/generated/iparity_i2.c
+++ b/libgfortran/generated/iparity_i2.c
@@ -242,8 +242,6 @@  miparity_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iparity_i4.c b/libgfortran/generated/iparity_i4.c
index 49f65145e15..c5c74c2e1d4 100644
--- a/libgfortran/generated/iparity_i4.c
+++ b/libgfortran/generated/iparity_i4.c
@@ -242,8 +242,6 @@  miparity_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/iparity_i8.c b/libgfortran/generated/iparity_i8.c
index ec68d514a48..aebc4f05833 100644
--- a/libgfortran/generated/iparity_i8.c
+++ b/libgfortran/generated/iparity_i8.c
@@ -242,8 +242,6 @@  miparity_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_i1.c b/libgfortran/generated/maxloc1_16_i1.c
index dd86eb22d95..66ac5f3cbf4 100644
--- a/libgfortran/generated/maxloc1_16_i1.c
+++ b/libgfortran/generated/maxloc1_16_i1.c
@@ -270,8 +270,6 @@  mmaxloc1_16_i1 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_i16.c b/libgfortran/generated/maxloc1_16_i16.c
index f40ade40214..445a4c4e53b 100644
--- a/libgfortran/generated/maxloc1_16_i16.c
+++ b/libgfortran/generated/maxloc1_16_i16.c
@@ -270,8 +270,6 @@  mmaxloc1_16_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_i2.c b/libgfortran/generated/maxloc1_16_i2.c
index d857d4fe768..ebae5ad552a 100644
--- a/libgfortran/generated/maxloc1_16_i2.c
+++ b/libgfortran/generated/maxloc1_16_i2.c
@@ -270,8 +270,6 @@  mmaxloc1_16_i2 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_i4.c b/libgfortran/generated/maxloc1_16_i4.c
index c67878b0f48..5e1019c119a 100644
--- a/libgfortran/generated/maxloc1_16_i4.c
+++ b/libgfortran/generated/maxloc1_16_i4.c
@@ -270,8 +270,6 @@  mmaxloc1_16_i4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_i8.c b/libgfortran/generated/maxloc1_16_i8.c
index 6e040811301..8c1a34bc213 100644
--- a/libgfortran/generated/maxloc1_16_i8.c
+++ b/libgfortran/generated/maxloc1_16_i8.c
@@ -270,8 +270,6 @@  mmaxloc1_16_i8 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_r10.c b/libgfortran/generated/maxloc1_16_r10.c
index 47d8f7ba619..602347a2db7 100644
--- a/libgfortran/generated/maxloc1_16_r10.c
+++ b/libgfortran/generated/maxloc1_16_r10.c
@@ -270,8 +270,6 @@  mmaxloc1_16_r10 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_r16.c b/libgfortran/generated/maxloc1_16_r16.c
index f5bd965205c..56b3130d698 100644
--- a/libgfortran/generated/maxloc1_16_r16.c
+++ b/libgfortran/generated/maxloc1_16_r16.c
@@ -270,8 +270,6 @@  mmaxloc1_16_r16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_r17.c b/libgfortran/generated/maxloc1_16_r17.c
index 8d59c196236..771c595c166 100644
--- a/libgfortran/generated/maxloc1_16_r17.c
+++ b/libgfortran/generated/maxloc1_16_r17.c
@@ -270,8 +270,6 @@  mmaxloc1_16_r17 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_r4.c b/libgfortran/generated/maxloc1_16_r4.c
index 91299bdcc01..ba3273f84fa 100644
--- a/libgfortran/generated/maxloc1_16_r4.c
+++ b/libgfortran/generated/maxloc1_16_r4.c
@@ -270,8 +270,6 @@  mmaxloc1_16_r4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_r8.c b/libgfortran/generated/maxloc1_16_r8.c
index 91e89b02a68..916c6bbb0da 100644
--- a/libgfortran/generated/maxloc1_16_r8.c
+++ b/libgfortran/generated/maxloc1_16_r8.c
@@ -270,8 +270,6 @@  mmaxloc1_16_r8 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_s1.c b/libgfortran/generated/maxloc1_16_s1.c
index 313ee1cf440..8032ed0c545 100644
--- a/libgfortran/generated/maxloc1_16_s1.c
+++ b/libgfortran/generated/maxloc1_16_s1.c
@@ -263,8 +263,6 @@  mmaxloc1_16_s1 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_16_s4.c b/libgfortran/generated/maxloc1_16_s4.c
index d8da8569e15..15b6af6032e 100644
--- a/libgfortran/generated/maxloc1_16_s4.c
+++ b/libgfortran/generated/maxloc1_16_s4.c
@@ -263,8 +263,6 @@  mmaxloc1_16_s4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_i1.c b/libgfortran/generated/maxloc1_4_i1.c
index 333b08cec96..3e90849cbe3 100644
--- a/libgfortran/generated/maxloc1_4_i1.c
+++ b/libgfortran/generated/maxloc1_4_i1.c
@@ -270,8 +270,6 @@  mmaxloc1_4_i1 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_i16.c b/libgfortran/generated/maxloc1_4_i16.c
index 62dadf6b66f..d41e3567468 100644
--- a/libgfortran/generated/maxloc1_4_i16.c
+++ b/libgfortran/generated/maxloc1_4_i16.c
@@ -270,8 +270,6 @@  mmaxloc1_4_i16 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_i2.c b/libgfortran/generated/maxloc1_4_i2.c
index 6bc6e500b52..5a931197e0b 100644
--- a/libgfortran/generated/maxloc1_4_i2.c
+++ b/libgfortran/generated/maxloc1_4_i2.c
@@ -270,8 +270,6 @@  mmaxloc1_4_i2 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_i4.c b/libgfortran/generated/maxloc1_4_i4.c
index d38fd367443..5eba4baa0f1 100644
--- a/libgfortran/generated/maxloc1_4_i4.c
+++ b/libgfortran/generated/maxloc1_4_i4.c
@@ -270,8 +270,6 @@  mmaxloc1_4_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_i8.c b/libgfortran/generated/maxloc1_4_i8.c
index 30314f0f6dd..f1293580afa 100644
--- a/libgfortran/generated/maxloc1_4_i8.c
+++ b/libgfortran/generated/maxloc1_4_i8.c
@@ -270,8 +270,6 @@  mmaxloc1_4_i8 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_r10.c b/libgfortran/generated/maxloc1_4_r10.c
index 693f52aef78..163b306ba70 100644
--- a/libgfortran/generated/maxloc1_4_r10.c
+++ b/libgfortran/generated/maxloc1_4_r10.c
@@ -270,8 +270,6 @@  mmaxloc1_4_r10 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_r16.c b/libgfortran/generated/maxloc1_4_r16.c
index c24dece73f6..cbde21450bc 100644
--- a/libgfortran/generated/maxloc1_4_r16.c
+++ b/libgfortran/generated/maxloc1_4_r16.c
@@ -270,8 +270,6 @@  mmaxloc1_4_r16 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_r17.c b/libgfortran/generated/maxloc1_4_r17.c
index a8efa10557e..24477055a4a 100644
--- a/libgfortran/generated/maxloc1_4_r17.c
+++ b/libgfortran/generated/maxloc1_4_r17.c
@@ -270,8 +270,6 @@  mmaxloc1_4_r17 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_r4.c b/libgfortran/generated/maxloc1_4_r4.c
index 6957da417ab..1ca7d7a8f09 100644
--- a/libgfortran/generated/maxloc1_4_r4.c
+++ b/libgfortran/generated/maxloc1_4_r4.c
@@ -270,8 +270,6 @@  mmaxloc1_4_r4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_r8.c b/libgfortran/generated/maxloc1_4_r8.c
index b7e6cf34774..41b42fcae51 100644
--- a/libgfortran/generated/maxloc1_4_r8.c
+++ b/libgfortran/generated/maxloc1_4_r8.c
@@ -270,8 +270,6 @@  mmaxloc1_4_r8 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_s1.c b/libgfortran/generated/maxloc1_4_s1.c
index 904c5d4a8fa..c7a967fe440 100644
--- a/libgfortran/generated/maxloc1_4_s1.c
+++ b/libgfortran/generated/maxloc1_4_s1.c
@@ -263,8 +263,6 @@  mmaxloc1_4_s1 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_4_s4.c b/libgfortran/generated/maxloc1_4_s4.c
index 5b1f7b0938d..68311d27d1e 100644
--- a/libgfortran/generated/maxloc1_4_s4.c
+++ b/libgfortran/generated/maxloc1_4_s4.c
@@ -263,8 +263,6 @@  mmaxloc1_4_s4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_i1.c b/libgfortran/generated/maxloc1_8_i1.c
index ee478907548..229bb97c357 100644
--- a/libgfortran/generated/maxloc1_8_i1.c
+++ b/libgfortran/generated/maxloc1_8_i1.c
@@ -270,8 +270,6 @@  mmaxloc1_8_i1 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_i16.c b/libgfortran/generated/maxloc1_8_i16.c
index 2c788a26d53..61b2c2c2ace 100644
--- a/libgfortran/generated/maxloc1_8_i16.c
+++ b/libgfortran/generated/maxloc1_8_i16.c
@@ -270,8 +270,6 @@  mmaxloc1_8_i16 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_i2.c b/libgfortran/generated/maxloc1_8_i2.c
index 13474427323..79386822e23 100644
--- a/libgfortran/generated/maxloc1_8_i2.c
+++ b/libgfortran/generated/maxloc1_8_i2.c
@@ -270,8 +270,6 @@  mmaxloc1_8_i2 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_i4.c b/libgfortran/generated/maxloc1_8_i4.c
index 57a001fefc6..6c92bde7499 100644
--- a/libgfortran/generated/maxloc1_8_i4.c
+++ b/libgfortran/generated/maxloc1_8_i4.c
@@ -270,8 +270,6 @@  mmaxloc1_8_i4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_i8.c b/libgfortran/generated/maxloc1_8_i8.c
index ff837e6872f..25efec05793 100644
--- a/libgfortran/generated/maxloc1_8_i8.c
+++ b/libgfortran/generated/maxloc1_8_i8.c
@@ -270,8 +270,6 @@  mmaxloc1_8_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_r10.c b/libgfortran/generated/maxloc1_8_r10.c
index 9046b279c12..5de342dc9c0 100644
--- a/libgfortran/generated/maxloc1_8_r10.c
+++ b/libgfortran/generated/maxloc1_8_r10.c
@@ -270,8 +270,6 @@  mmaxloc1_8_r10 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_r16.c b/libgfortran/generated/maxloc1_8_r16.c
index 93e83307da4..57e53d43225 100644
--- a/libgfortran/generated/maxloc1_8_r16.c
+++ b/libgfortran/generated/maxloc1_8_r16.c
@@ -270,8 +270,6 @@  mmaxloc1_8_r16 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_r17.c b/libgfortran/generated/maxloc1_8_r17.c
index ab14e3a7ebe..0e108aa37d9 100644
--- a/libgfortran/generated/maxloc1_8_r17.c
+++ b/libgfortran/generated/maxloc1_8_r17.c
@@ -270,8 +270,6 @@  mmaxloc1_8_r17 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_r4.c b/libgfortran/generated/maxloc1_8_r4.c
index 556357b46a1..f8d3305b898 100644
--- a/libgfortran/generated/maxloc1_8_r4.c
+++ b/libgfortran/generated/maxloc1_8_r4.c
@@ -270,8 +270,6 @@  mmaxloc1_8_r4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_r8.c b/libgfortran/generated/maxloc1_8_r8.c
index aceebcf7cf4..74119b89aea 100644
--- a/libgfortran/generated/maxloc1_8_r8.c
+++ b/libgfortran/generated/maxloc1_8_r8.c
@@ -270,8 +270,6 @@  mmaxloc1_8_r8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_s1.c b/libgfortran/generated/maxloc1_8_s1.c
index 9659f7f74a6..6b905eb5995 100644
--- a/libgfortran/generated/maxloc1_8_s1.c
+++ b/libgfortran/generated/maxloc1_8_s1.c
@@ -263,8 +263,6 @@  mmaxloc1_8_s1 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxloc1_8_s4.c b/libgfortran/generated/maxloc1_8_s4.c
index 10302b95ade..5bc8ce4ffbd 100644
--- a/libgfortran/generated/maxloc1_8_s4.c
+++ b/libgfortran/generated/maxloc1_8_s4.c
@@ -263,8 +263,6 @@  mmaxloc1_8_s4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval1_s1.c b/libgfortran/generated/maxval1_s1.c
index 605e04b4e2e..d9094913e86 100644
--- a/libgfortran/generated/maxval1_s1.c
+++ b/libgfortran/generated/maxval1_s1.c
@@ -258,8 +258,6 @@  mmaxval1_s1 (gfc_array_s1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval1_s4.c b/libgfortran/generated/maxval1_s4.c
index 829cdf213c1..ab1b33ad4a3 100644
--- a/libgfortran/generated/maxval1_s4.c
+++ b/libgfortran/generated/maxval1_s4.c
@@ -258,8 +258,6 @@  mmaxval1_s4 (gfc_array_s4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_i1.c b/libgfortran/generated/maxval_i1.c
index 04faea82a9e..11c75d21616 100644
--- a/libgfortran/generated/maxval_i1.c
+++ b/libgfortran/generated/maxval_i1.c
@@ -256,8 +256,6 @@  mmaxval_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_i16.c b/libgfortran/generated/maxval_i16.c
index eaaaf7f55b3..8608393cd0d 100644
--- a/libgfortran/generated/maxval_i16.c
+++ b/libgfortran/generated/maxval_i16.c
@@ -256,8 +256,6 @@  mmaxval_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_i2.c b/libgfortran/generated/maxval_i2.c
index 440226d2fff..e722773120c 100644
--- a/libgfortran/generated/maxval_i2.c
+++ b/libgfortran/generated/maxval_i2.c
@@ -256,8 +256,6 @@  mmaxval_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_i4.c b/libgfortran/generated/maxval_i4.c
index 99248447c31..0d5401153c8 100644
--- a/libgfortran/generated/maxval_i4.c
+++ b/libgfortran/generated/maxval_i4.c
@@ -256,8 +256,6 @@  mmaxval_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_i8.c b/libgfortran/generated/maxval_i8.c
index cb14e74486f..5a15f768b9d 100644
--- a/libgfortran/generated/maxval_i8.c
+++ b/libgfortran/generated/maxval_i8.c
@@ -256,8 +256,6 @@  mmaxval_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_r10.c b/libgfortran/generated/maxval_r10.c
index 9fb9b0297c9..aa781b9a4b0 100644
--- a/libgfortran/generated/maxval_r10.c
+++ b/libgfortran/generated/maxval_r10.c
@@ -256,8 +256,6 @@  mmaxval_r10 (gfc_array_r10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_r16.c b/libgfortran/generated/maxval_r16.c
index b06ea6653db..1dfc0514907 100644
--- a/libgfortran/generated/maxval_r16.c
+++ b/libgfortran/generated/maxval_r16.c
@@ -256,8 +256,6 @@  mmaxval_r16 (gfc_array_r16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_r17.c b/libgfortran/generated/maxval_r17.c
index 1ec11fff1f2..50e4614a9d1 100644
--- a/libgfortran/generated/maxval_r17.c
+++ b/libgfortran/generated/maxval_r17.c
@@ -256,8 +256,6 @@  mmaxval_r17 (gfc_array_r17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_r4.c b/libgfortran/generated/maxval_r4.c
index 8dfde41fa0c..c3f03038b6a 100644
--- a/libgfortran/generated/maxval_r4.c
+++ b/libgfortran/generated/maxval_r4.c
@@ -256,8 +256,6 @@  mmaxval_r4 (gfc_array_r4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/maxval_r8.c b/libgfortran/generated/maxval_r8.c
index 179a4227179..9954a3f8c66 100644
--- a/libgfortran/generated/maxval_r8.c
+++ b/libgfortran/generated/maxval_r8.c
@@ -256,8 +256,6 @@  mmaxval_r8 (gfc_array_r8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_i1.c b/libgfortran/generated/minloc1_16_i1.c
index 7bca02e91de..ab16257db2f 100644
--- a/libgfortran/generated/minloc1_16_i1.c
+++ b/libgfortran/generated/minloc1_16_i1.c
@@ -280,8 +280,6 @@  mminloc1_16_i1 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_i16.c b/libgfortran/generated/minloc1_16_i16.c
index 1876871f7ca..98bd80a0978 100644
--- a/libgfortran/generated/minloc1_16_i16.c
+++ b/libgfortran/generated/minloc1_16_i16.c
@@ -280,8 +280,6 @@  mminloc1_16_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_i2.c b/libgfortran/generated/minloc1_16_i2.c
index 061a7928912..0351f284cff 100644
--- a/libgfortran/generated/minloc1_16_i2.c
+++ b/libgfortran/generated/minloc1_16_i2.c
@@ -280,8 +280,6 @@  mminloc1_16_i2 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_i4.c b/libgfortran/generated/minloc1_16_i4.c
index 297d7c53605..469d9a544a6 100644
--- a/libgfortran/generated/minloc1_16_i4.c
+++ b/libgfortran/generated/minloc1_16_i4.c
@@ -280,8 +280,6 @@  mminloc1_16_i4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_i8.c b/libgfortran/generated/minloc1_16_i8.c
index d0bfb654596..f027f240ccf 100644
--- a/libgfortran/generated/minloc1_16_i8.c
+++ b/libgfortran/generated/minloc1_16_i8.c
@@ -280,8 +280,6 @@  mminloc1_16_i8 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_r10.c b/libgfortran/generated/minloc1_16_r10.c
index 8fc8399ad43..fa019e8518a 100644
--- a/libgfortran/generated/minloc1_16_r10.c
+++ b/libgfortran/generated/minloc1_16_r10.c
@@ -280,8 +280,6 @@  mminloc1_16_r10 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_r16.c b/libgfortran/generated/minloc1_16_r16.c
index 3efb7fbb9cd..b588aebd07d 100644
--- a/libgfortran/generated/minloc1_16_r16.c
+++ b/libgfortran/generated/minloc1_16_r16.c
@@ -280,8 +280,6 @@  mminloc1_16_r16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_r17.c b/libgfortran/generated/minloc1_16_r17.c
index bcffa58b2a0..c3df2151e43 100644
--- a/libgfortran/generated/minloc1_16_r17.c
+++ b/libgfortran/generated/minloc1_16_r17.c
@@ -280,8 +280,6 @@  mminloc1_16_r17 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_r4.c b/libgfortran/generated/minloc1_16_r4.c
index 6b25af9743f..4ba9e19d6cc 100644
--- a/libgfortran/generated/minloc1_16_r4.c
+++ b/libgfortran/generated/minloc1_16_r4.c
@@ -280,8 +280,6 @@  mminloc1_16_r4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_r8.c b/libgfortran/generated/minloc1_16_r8.c
index f3f88c35cf0..9dcd143b1e4 100644
--- a/libgfortran/generated/minloc1_16_r8.c
+++ b/libgfortran/generated/minloc1_16_r8.c
@@ -280,8 +280,6 @@  mminloc1_16_r8 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_s1.c b/libgfortran/generated/minloc1_16_s1.c
index 3419055dc70..d7bbecf0bbd 100644
--- a/libgfortran/generated/minloc1_16_s1.c
+++ b/libgfortran/generated/minloc1_16_s1.c
@@ -263,8 +263,6 @@  mminloc1_16_s1 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_16_s4.c b/libgfortran/generated/minloc1_16_s4.c
index aad2f87386f..860abd58a8d 100644
--- a/libgfortran/generated/minloc1_16_s4.c
+++ b/libgfortran/generated/minloc1_16_s4.c
@@ -263,8 +263,6 @@  mminloc1_16_s4 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_i1.c b/libgfortran/generated/minloc1_4_i1.c
index 8e2ccace944..a970851c773 100644
--- a/libgfortran/generated/minloc1_4_i1.c
+++ b/libgfortran/generated/minloc1_4_i1.c
@@ -280,8 +280,6 @@  mminloc1_4_i1 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_i16.c b/libgfortran/generated/minloc1_4_i16.c
index 3236418f64e..9df9e185f3f 100644
--- a/libgfortran/generated/minloc1_4_i16.c
+++ b/libgfortran/generated/minloc1_4_i16.c
@@ -280,8 +280,6 @@  mminloc1_4_i16 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_i2.c b/libgfortran/generated/minloc1_4_i2.c
index f039cc2df88..ad74b523c37 100644
--- a/libgfortran/generated/minloc1_4_i2.c
+++ b/libgfortran/generated/minloc1_4_i2.c
@@ -280,8 +280,6 @@  mminloc1_4_i2 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_i4.c b/libgfortran/generated/minloc1_4_i4.c
index 0eac1a8de9e..a8a63fb0a8b 100644
--- a/libgfortran/generated/minloc1_4_i4.c
+++ b/libgfortran/generated/minloc1_4_i4.c
@@ -280,8 +280,6 @@  mminloc1_4_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_i8.c b/libgfortran/generated/minloc1_4_i8.c
index b6fc26765c2..fbecd43fa1a 100644
--- a/libgfortran/generated/minloc1_4_i8.c
+++ b/libgfortran/generated/minloc1_4_i8.c
@@ -280,8 +280,6 @@  mminloc1_4_i8 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_r10.c b/libgfortran/generated/minloc1_4_r10.c
index 3245be44d42..154cc016d0b 100644
--- a/libgfortran/generated/minloc1_4_r10.c
+++ b/libgfortran/generated/minloc1_4_r10.c
@@ -280,8 +280,6 @@  mminloc1_4_r10 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_r16.c b/libgfortran/generated/minloc1_4_r16.c
index a0ca94a653f..6ee86021840 100644
--- a/libgfortran/generated/minloc1_4_r16.c
+++ b/libgfortran/generated/minloc1_4_r16.c
@@ -280,8 +280,6 @@  mminloc1_4_r16 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_r17.c b/libgfortran/generated/minloc1_4_r17.c
index 56b438aea7d..c2cdfbc88c6 100644
--- a/libgfortran/generated/minloc1_4_r17.c
+++ b/libgfortran/generated/minloc1_4_r17.c
@@ -280,8 +280,6 @@  mminloc1_4_r17 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_r4.c b/libgfortran/generated/minloc1_4_r4.c
index 922cca690e0..f0a805fdf75 100644
--- a/libgfortran/generated/minloc1_4_r4.c
+++ b/libgfortran/generated/minloc1_4_r4.c
@@ -280,8 +280,6 @@  mminloc1_4_r4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_r8.c b/libgfortran/generated/minloc1_4_r8.c
index 7316d6e2663..97dbb15e824 100644
--- a/libgfortran/generated/minloc1_4_r8.c
+++ b/libgfortran/generated/minloc1_4_r8.c
@@ -280,8 +280,6 @@  mminloc1_4_r8 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_s1.c b/libgfortran/generated/minloc1_4_s1.c
index da8e49a8029..1d3bfbdef15 100644
--- a/libgfortran/generated/minloc1_4_s1.c
+++ b/libgfortran/generated/minloc1_4_s1.c
@@ -263,8 +263,6 @@  mminloc1_4_s1 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_4_s4.c b/libgfortran/generated/minloc1_4_s4.c
index ca708992ede..cfdff545f32 100644
--- a/libgfortran/generated/minloc1_4_s4.c
+++ b/libgfortran/generated/minloc1_4_s4.c
@@ -263,8 +263,6 @@  mminloc1_4_s4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_i1.c b/libgfortran/generated/minloc1_8_i1.c
index de8603cc1f2..0cccb4f8186 100644
--- a/libgfortran/generated/minloc1_8_i1.c
+++ b/libgfortran/generated/minloc1_8_i1.c
@@ -280,8 +280,6 @@  mminloc1_8_i1 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_i16.c b/libgfortran/generated/minloc1_8_i16.c
index 01a4e37869a..6c66f84d68e 100644
--- a/libgfortran/generated/minloc1_8_i16.c
+++ b/libgfortran/generated/minloc1_8_i16.c
@@ -280,8 +280,6 @@  mminloc1_8_i16 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_i2.c b/libgfortran/generated/minloc1_8_i2.c
index e020bfe3b49..ea24ead4b4a 100644
--- a/libgfortran/generated/minloc1_8_i2.c
+++ b/libgfortran/generated/minloc1_8_i2.c
@@ -280,8 +280,6 @@  mminloc1_8_i2 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_i4.c b/libgfortran/generated/minloc1_8_i4.c
index f5093f13bc0..b55bc480bf5 100644
--- a/libgfortran/generated/minloc1_8_i4.c
+++ b/libgfortran/generated/minloc1_8_i4.c
@@ -280,8 +280,6 @@  mminloc1_8_i4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_i8.c b/libgfortran/generated/minloc1_8_i8.c
index 5b3a327abc5..44b6107cc26 100644
--- a/libgfortran/generated/minloc1_8_i8.c
+++ b/libgfortran/generated/minloc1_8_i8.c
@@ -280,8 +280,6 @@  mminloc1_8_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_r10.c b/libgfortran/generated/minloc1_8_r10.c
index 280840f33e6..b093b3f6ad0 100644
--- a/libgfortran/generated/minloc1_8_r10.c
+++ b/libgfortran/generated/minloc1_8_r10.c
@@ -280,8 +280,6 @@  mminloc1_8_r10 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_r16.c b/libgfortran/generated/minloc1_8_r16.c
index fd0ee3e6c7b..7c660c828ac 100644
--- a/libgfortran/generated/minloc1_8_r16.c
+++ b/libgfortran/generated/minloc1_8_r16.c
@@ -280,8 +280,6 @@  mminloc1_8_r16 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_r17.c b/libgfortran/generated/minloc1_8_r17.c
index dcb3f929842..f9c95330b32 100644
--- a/libgfortran/generated/minloc1_8_r17.c
+++ b/libgfortran/generated/minloc1_8_r17.c
@@ -280,8 +280,6 @@  mminloc1_8_r17 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_r4.c b/libgfortran/generated/minloc1_8_r4.c
index e6025482211..b0956bdd81a 100644
--- a/libgfortran/generated/minloc1_8_r4.c
+++ b/libgfortran/generated/minloc1_8_r4.c
@@ -280,8 +280,6 @@  mminloc1_8_r4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_r8.c b/libgfortran/generated/minloc1_8_r8.c
index e18185fc6fe..da96e942f2d 100644
--- a/libgfortran/generated/minloc1_8_r8.c
+++ b/libgfortran/generated/minloc1_8_r8.c
@@ -280,8 +280,6 @@  mminloc1_8_r8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_s1.c b/libgfortran/generated/minloc1_8_s1.c
index 6e26878fc02..1f091780339 100644
--- a/libgfortran/generated/minloc1_8_s1.c
+++ b/libgfortran/generated/minloc1_8_s1.c
@@ -263,8 +263,6 @@  mminloc1_8_s1 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minloc1_8_s4.c b/libgfortran/generated/minloc1_8_s4.c
index 14e5c9e7395..5a04345e0a9 100644
--- a/libgfortran/generated/minloc1_8_s4.c
+++ b/libgfortran/generated/minloc1_8_s4.c
@@ -263,8 +263,6 @@  mminloc1_8_s4 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval1_s1.c b/libgfortran/generated/minval1_s1.c
index 3a1cde20f93..60f65fd9439 100644
--- a/libgfortran/generated/minval1_s1.c
+++ b/libgfortran/generated/minval1_s1.c
@@ -258,8 +258,6 @@  mminval1_s1 (gfc_array_s1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval1_s4.c b/libgfortran/generated/minval1_s4.c
index 83987fd1f25..e8252991a18 100644
--- a/libgfortran/generated/minval1_s4.c
+++ b/libgfortran/generated/minval1_s4.c
@@ -258,8 +258,6 @@  mminval1_s4 (gfc_array_s4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_i1.c b/libgfortran/generated/minval_i1.c
index 4b3d19e15f2..352380d8a12 100644
--- a/libgfortran/generated/minval_i1.c
+++ b/libgfortran/generated/minval_i1.c
@@ -256,8 +256,6 @@  mminval_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_i16.c b/libgfortran/generated/minval_i16.c
index de746524499..a9bd75070fd 100644
--- a/libgfortran/generated/minval_i16.c
+++ b/libgfortran/generated/minval_i16.c
@@ -256,8 +256,6 @@  mminval_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_i2.c b/libgfortran/generated/minval_i2.c
index 8bcaeb7b866..990b47adafe 100644
--- a/libgfortran/generated/minval_i2.c
+++ b/libgfortran/generated/minval_i2.c
@@ -256,8 +256,6 @@  mminval_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_i4.c b/libgfortran/generated/minval_i4.c
index a45aaae0bc6..237242cbf1c 100644
--- a/libgfortran/generated/minval_i4.c
+++ b/libgfortran/generated/minval_i4.c
@@ -256,8 +256,6 @@  mminval_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_i8.c b/libgfortran/generated/minval_i8.c
index 481b5d093d2..61f26acf2b5 100644
--- a/libgfortran/generated/minval_i8.c
+++ b/libgfortran/generated/minval_i8.c
@@ -256,8 +256,6 @@  mminval_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_r10.c b/libgfortran/generated/minval_r10.c
index e0f7c78a2af..63f21e966d4 100644
--- a/libgfortran/generated/minval_r10.c
+++ b/libgfortran/generated/minval_r10.c
@@ -256,8 +256,6 @@  mminval_r10 (gfc_array_r10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_r16.c b/libgfortran/generated/minval_r16.c
index 41feafb17db..ae9b1223b8e 100644
--- a/libgfortran/generated/minval_r16.c
+++ b/libgfortran/generated/minval_r16.c
@@ -256,8 +256,6 @@  mminval_r16 (gfc_array_r16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_r17.c b/libgfortran/generated/minval_r17.c
index d928240bf1a..fc1b6ba4e9b 100644
--- a/libgfortran/generated/minval_r17.c
+++ b/libgfortran/generated/minval_r17.c
@@ -256,8 +256,6 @@  mminval_r17 (gfc_array_r17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_r4.c b/libgfortran/generated/minval_r4.c
index 7d16b6f5c93..010fb9e5a09 100644
--- a/libgfortran/generated/minval_r4.c
+++ b/libgfortran/generated/minval_r4.c
@@ -256,8 +256,6 @@  mminval_r4 (gfc_array_r4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/minval_r8.c b/libgfortran/generated/minval_r8.c
index 7a2cb031115..c9a6b0d9da8 100644
--- a/libgfortran/generated/minval_r8.c
+++ b/libgfortran/generated/minval_r8.c
@@ -256,8 +256,6 @@  mminval_r8 (gfc_array_r8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_c10.c b/libgfortran/generated/product_c10.c
index 992313feabe..7b97f6b5161 100644
--- a/libgfortran/generated/product_c10.c
+++ b/libgfortran/generated/product_c10.c
@@ -242,8 +242,6 @@  mproduct_c10 (gfc_array_c10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_c16.c b/libgfortran/generated/product_c16.c
index 468c6aa86de..202b90ac288 100644
--- a/libgfortran/generated/product_c16.c
+++ b/libgfortran/generated/product_c16.c
@@ -242,8 +242,6 @@  mproduct_c16 (gfc_array_c16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_c17.c b/libgfortran/generated/product_c17.c
index e7221738b59..49e87391315 100644
--- a/libgfortran/generated/product_c17.c
+++ b/libgfortran/generated/product_c17.c
@@ -242,8 +242,6 @@  mproduct_c17 (gfc_array_c17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_c4.c b/libgfortran/generated/product_c4.c
index 57875ad2984..513557c740e 100644
--- a/libgfortran/generated/product_c4.c
+++ b/libgfortran/generated/product_c4.c
@@ -242,8 +242,6 @@  mproduct_c4 (gfc_array_c4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_c8.c b/libgfortran/generated/product_c8.c
index fb8a2574542..5de40c6e43c 100644
--- a/libgfortran/generated/product_c8.c
+++ b/libgfortran/generated/product_c8.c
@@ -242,8 +242,6 @@  mproduct_c8 (gfc_array_c8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_i1.c b/libgfortran/generated/product_i1.c
index ed13fcf37e4..0502bdfa845 100644
--- a/libgfortran/generated/product_i1.c
+++ b/libgfortran/generated/product_i1.c
@@ -242,8 +242,6 @@  mproduct_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_i16.c b/libgfortran/generated/product_i16.c
index 53544bea8f0..41f7cb5fde0 100644
--- a/libgfortran/generated/product_i16.c
+++ b/libgfortran/generated/product_i16.c
@@ -242,8 +242,6 @@  mproduct_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_i2.c b/libgfortran/generated/product_i2.c
index aef0fc47d4f..cfd5291634d 100644
--- a/libgfortran/generated/product_i2.c
+++ b/libgfortran/generated/product_i2.c
@@ -242,8 +242,6 @@  mproduct_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_i4.c b/libgfortran/generated/product_i4.c
index 16c6f6e10ae..9482e3fd64e 100644
--- a/libgfortran/generated/product_i4.c
+++ b/libgfortran/generated/product_i4.c
@@ -242,8 +242,6 @@  mproduct_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_i8.c b/libgfortran/generated/product_i8.c
index 66f581f4b2d..38ae86199be 100644
--- a/libgfortran/generated/product_i8.c
+++ b/libgfortran/generated/product_i8.c
@@ -242,8 +242,6 @@  mproduct_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_r10.c b/libgfortran/generated/product_r10.c
index 8c79ff88a6f..63fb76dfd30 100644
--- a/libgfortran/generated/product_r10.c
+++ b/libgfortran/generated/product_r10.c
@@ -242,8 +242,6 @@  mproduct_r10 (gfc_array_r10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_r16.c b/libgfortran/generated/product_r16.c
index 0f5027be42f..d6a67c8c68c 100644
--- a/libgfortran/generated/product_r16.c
+++ b/libgfortran/generated/product_r16.c
@@ -242,8 +242,6 @@  mproduct_r16 (gfc_array_r16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_r17.c b/libgfortran/generated/product_r17.c
index 37134cbb089..c927057225a 100644
--- a/libgfortran/generated/product_r17.c
+++ b/libgfortran/generated/product_r17.c
@@ -242,8 +242,6 @@  mproduct_r17 (gfc_array_r17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_r4.c b/libgfortran/generated/product_r4.c
index 9a8eefb5124..8167b8215f1 100644
--- a/libgfortran/generated/product_r4.c
+++ b/libgfortran/generated/product_r4.c
@@ -242,8 +242,6 @@  mproduct_r4 (gfc_array_r4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/product_r8.c b/libgfortran/generated/product_r8.c
index 5112b90f5f2..2c0a231c3f7 100644
--- a/libgfortran/generated/product_r8.c
+++ b/libgfortran/generated/product_r8.c
@@ -242,8 +242,6 @@  mproduct_r8 (gfc_array_r8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_c10.c b/libgfortran/generated/sum_c10.c
index d6a5db64fca..b3c8b790c9d 100644
--- a/libgfortran/generated/sum_c10.c
+++ b/libgfortran/generated/sum_c10.c
@@ -242,8 +242,6 @@  msum_c10 (gfc_array_c10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_c16.c b/libgfortran/generated/sum_c16.c
index 156382d2f33..aa912e7d659 100644
--- a/libgfortran/generated/sum_c16.c
+++ b/libgfortran/generated/sum_c16.c
@@ -242,8 +242,6 @@  msum_c16 (gfc_array_c16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_c17.c b/libgfortran/generated/sum_c17.c
index c00b0b84d5d..ea6514ae08e 100644
--- a/libgfortran/generated/sum_c17.c
+++ b/libgfortran/generated/sum_c17.c
@@ -242,8 +242,6 @@  msum_c17 (gfc_array_c17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_c4.c b/libgfortran/generated/sum_c4.c
index b750a91f940..6c02d6381f2 100644
--- a/libgfortran/generated/sum_c4.c
+++ b/libgfortran/generated/sum_c4.c
@@ -242,8 +242,6 @@  msum_c4 (gfc_array_c4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_c8.c b/libgfortran/generated/sum_c8.c
index 19b03c07504..eb4641d447f 100644
--- a/libgfortran/generated/sum_c8.c
+++ b/libgfortran/generated/sum_c8.c
@@ -242,8 +242,6 @@  msum_c8 (gfc_array_c8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_i1.c b/libgfortran/generated/sum_i1.c
index 2df0ec11a87..27d80284296 100644
--- a/libgfortran/generated/sum_i1.c
+++ b/libgfortran/generated/sum_i1.c
@@ -242,8 +242,6 @@  msum_i1 (gfc_array_i1 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_i16.c b/libgfortran/generated/sum_i16.c
index 0b7179b595d..592ae925493 100644
--- a/libgfortran/generated/sum_i16.c
+++ b/libgfortran/generated/sum_i16.c
@@ -242,8 +242,6 @@  msum_i16 (gfc_array_i16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_i2.c b/libgfortran/generated/sum_i2.c
index 3149e5fe5e5..54d91ab1a43 100644
--- a/libgfortran/generated/sum_i2.c
+++ b/libgfortran/generated/sum_i2.c
@@ -242,8 +242,6 @@  msum_i2 (gfc_array_i2 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_i4.c b/libgfortran/generated/sum_i4.c
index 5cf5f95bf0f..aa27839110d 100644
--- a/libgfortran/generated/sum_i4.c
+++ b/libgfortran/generated/sum_i4.c
@@ -242,8 +242,6 @@  msum_i4 (gfc_array_i4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_i8.c b/libgfortran/generated/sum_i8.c
index a020ba63349..a7836ed99f4 100644
--- a/libgfortran/generated/sum_i8.c
+++ b/libgfortran/generated/sum_i8.c
@@ -242,8 +242,6 @@  msum_i8 (gfc_array_i8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_r10.c b/libgfortran/generated/sum_r10.c
index f02f9816b7d..5efe6a2bce4 100644
--- a/libgfortran/generated/sum_r10.c
+++ b/libgfortran/generated/sum_r10.c
@@ -242,8 +242,6 @@  msum_r10 (gfc_array_r10 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_r16.c b/libgfortran/generated/sum_r16.c
index 43439ef385c..feedb4a5139 100644
--- a/libgfortran/generated/sum_r16.c
+++ b/libgfortran/generated/sum_r16.c
@@ -242,8 +242,6 @@  msum_r16 (gfc_array_r16 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_r17.c b/libgfortran/generated/sum_r17.c
index 97af0d73a77..fdbf84783a9 100644
--- a/libgfortran/generated/sum_r17.c
+++ b/libgfortran/generated/sum_r17.c
@@ -242,8 +242,6 @@  msum_r17 (gfc_array_r17 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_r4.c b/libgfortran/generated/sum_r4.c
index 5a4e06a5545..4a7ab4a6c1a 100644
--- a/libgfortran/generated/sum_r4.c
+++ b/libgfortran/generated/sum_r4.c
@@ -242,8 +242,6 @@  msum_r4 (gfc_array_r4 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/generated/sum_r8.c b/libgfortran/generated/sum_r8.c
index 00f7cdba540..a83dd93348f 100644
--- a/libgfortran/generated/sum_r8.c
+++ b/libgfortran/generated/sum_r8.c
@@ -242,8 +242,6 @@  msum_r8 (gfc_array_r8 * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/m4/ifunction-s.m4 b/libgfortran/m4/ifunction-s.m4
index 16615aa290f..19f665f50ad 100644
--- a/libgfortran/m4/ifunction-s.m4
+++ b/libgfortran/m4/ifunction-s.m4
@@ -244,8 +244,6 @@  m'name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/m4/ifunction-s2.m4 b/libgfortran/m4/ifunction-s2.m4
index 4d31c208e05..5d9870e8640 100644
--- a/libgfortran/m4/ifunction-s2.m4
+++ b/libgfortran/m4/ifunction-s2.m4
@@ -244,8 +244,6 @@  void
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;
 
diff --git a/libgfortran/m4/ifunction.m4 b/libgfortran/m4/ifunction.m4
index c64217ec5db..480649cf691 100644
--- a/libgfortran/m4/ifunction.m4
+++ b/libgfortran/m4/ifunction.m4
@@ -232,8 +232,6 @@  m'name`'rtype_qual`_'atype_code` ('rtype` * const restrict retarray,
     }
 
   len = GFC_DESCRIPTOR_EXTENT(array,dim);
-  if (len <= 0)
-    return;
 
   mbase = mask->base_addr;