From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.smtpout.orange.fr (smtp-24.smtpout.orange.fr [80.12.242.24]) by sourceware.org (Postfix) with ESMTPS id 6B93C3858D20 for ; Mon, 6 Nov 2023 18:57:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B93C3858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=orange.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=orange.fr ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6B93C3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=80.12.242.24 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699297076; cv=none; b=afCRk8C5BGyTorxNzzgVp0UKl9bWCT7wkG2qamaFYtE1tYPv6A2Nt3DMP3xMJ3NzU5Ca7DMZavd79+B6xAaVs3uCVYbwgDEhFILGrDZuUSFkG0dpNAeUkmueNvd9X2LPEPDWwzEQqjGptEohOsozFa0Jcq64Hasq89jMfVoKPtI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699297076; c=relaxed/simple; bh=xlffYWtijmHYaTVNU0SqI9gGDTYC86X+lCl/LIM1QGI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=OiN+MVsZJ7WhBKjoYwyFOs0HoGYT9INLac+ghuzpsHlu2qRftSKRo8dLngNyWHK5e0eWsh6CEoOuhJpmmrIF7CrMU8SrWk2ufde+xTvJy9pFWlbUlmJ3HvGiaqUWGbWbRcYudSgdfjdcaGl8oVfJjJBxPVGZEbdLhTAWt48chL4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [192.168.1.13] ([86.215.161.51]) by smtp.orange.fr with ESMTPA id 04nAruPxvmbB104nIrjvyJ; Mon, 06 Nov 2023 19:57:53 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1699297073; bh=XgxvqoyHSsTco0SefeBYVGV4jwJloGK2CSB1PdWCcZM=; h=Date:Subject:To:References:From:In-Reply-To; b=Wf3V5blWg+ubEyqgmRa661vjOvhDabne2t0bU9z7Jsx+8JwQBDLLNoYpl8bs4VlmN jW04pBIWdgabXzpJTJCZ8uxPmWdnYqlExjJLNBpm/v6wUjDPSPqCrH2FkfP7T4XZgb WN1k2zyAQzBwjqzSivtRpMHz8P4NNr0EzbqKIHWFubTIIfATlrqshD/bVQ4bEsMZBP X5Z88F6h8pQDyII529JldvmGVu5TEzACyzmx+MZF0emA1M7FwIKcyL3GxWUtMMoQx/ AFlhb1v+7VWE34Hu9Ecmrs+pDtYol5pQoObqlLXKbm0bPCHDmHOu0Q+R7P3u4bqfs1 AepRGdwF29I1w== X-ME-Helo: [192.168.1.13] X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Mon, 06 Nov 2023 19:57:53 +0100 X-ME-IP: 86.215.161.51 Message-ID: Date: Mon, 6 Nov 2023 19:57:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] libgfortran: Remove early return if extent is zero [PR112371] To: Harald Anlauf , Mikael Morin , gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org References: <20231106114325.828968-1-mikael@gcc.gnu.org> <20231106114325.828968-2-mikael@gcc.gnu.org> <8e65205b-fbe9-40fb-ba72-a77ab87ab688@gmx.de> Content-Language: en-US From: Mikael Morin In-Reply-To: <8e65205b-fbe9-40fb-ba72-a77ab87ab688@gmx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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.