From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 2BEFB3951C0F for ; Thu, 13 Jan 2022 13:50:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2BEFB3951C0F Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BE23AED1; Thu, 13 Jan 2022 05:50:58 -0800 (PST) Received: from [10.57.11.97] (unknown [10.57.11.97]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 359843F766; Thu, 13 Jan 2022 05:50:58 -0800 (PST) Message-ID: <57df4982-3c4d-d170-5b28-cfa3b375586e@arm.com> Date: Thu, 13 Jan 2022 13:51:03 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Subject: Re: [vect] PR103997: Fix epilogue mode skipping Content-Language: en-US To: Richard Biener Cc: "gcc-patches@gcc.gnu.org" , Richard Sandiford References: <51da8b34-511c-4359-b7d8-786935417c70@arm.com> <8419o610-p15n-r889-r411-37616134p348@fhfr.qr> From: "Andre Vieira (lists)" In-Reply-To: <8419o610-p15n-r889-r411-37616134p348@fhfr.qr> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Jan 2022 13:51:00 -0000 On 13/01/2022 12:36, Richard Biener wrote: > On Thu, 13 Jan 2022, Andre Vieira (lists) wrote: > >> This time to the list too (sorry for double email) >> >> Hi, >> >> The original patch '[vect] Re-analyze all modes for epilogues', skipped modes >> that should not be skipped since it used the vector mode provided by >> autovectorize_vector_modes to derive the minimum VF required for it. However, >> those modes should only really be used to dictate vector size, so instead this >> patch looks for the mode in 'used_vector_modes' with the largest element size, >> and constructs a vector mode with the smae size as the current >> vector_modes[mode_i]. Since we are using the largest element size the NUNITs >> for this mode is the smallest possible VF required for an epilogue with this >> mode and should thus skip only the modes we are certain can not be used. >> >> Passes bootstrap and regression on x86_64 and aarch64. > Clearly > > + /* To make sure we are conservative as to what modes we skip, we > + should use check the smallest possible NUNITS which would be > + derived from the mode in USED_VECTOR_MODES with the largest > + element size. */ > + scalar_mode max_elsize_mode = GET_MODE_INNER > (vector_modes[mode_i]); > + for (vec_info::mode_set::iterator i = > + first_loop_vinfo->used_vector_modes.begin (); > + i != first_loop_vinfo->used_vector_modes.end (); ++i) > + { > + if (VECTOR_MODE_P (*i) > + && GET_MODE_SIZE (GET_MODE_INNER (*i)) > + > GET_MODE_SIZE (max_elsize_mode)) > + max_elsize_mode = GET_MODE_INNER (*i); > + } > > can be done once before iterating over the modes for the epilogue. True, I'll start with QImode instead of the inner of vector_modes[mode_i] too since we can't guarantee the mode is a VECTOR_MODE_P and it is actually better too since we can't possible guarantee the element size of the USED_VECTOR_MODES is smaller than that of the first vector mode... > Richard maybe knows whether we should take care to look at the > size of the vector mode as well since related_vector_mode when > passed 0 as nunits produces a vector mode with the same size > as vector_modes[mode_i] but not all used_vector_modes may be > of the same size I suspect that should be fine though, since if we use the largest element size of all used_vector_modes then that should gives us the least possible number of NUNITS and thus only conservatively skip. That said, that does assume that no vector mode used may be larger than the size of the loop's vector_mode. Can I assume that? > > (and you probably also want to exclude > VECTOR_BOOLEAN_TYPE_P from the search?) Yeah I think so too, thanks! I keep going back to thinking (as I brought up in the bugzilla ticket), maybe we ought to only skip if the NUNITS of the vector mode with the same vector size as vector_modes[mode_i] is larger than first_info_vf, or just don't skip at all...