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 373293858CD1; Fri, 11 Aug 2023 13:23:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 373293858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com 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 35C0A113E; Fri, 11 Aug 2023 06:23:47 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0B4613F6C4; Fri, 11 Aug 2023 06:23:03 -0700 (PDT) From: Richard Sandiford To: Richard Biener Mail-Followup-To: Richard Biener ,"juzhe.zhong\@rivai.ai" , gcc-patches , linkw , krebbel , richard.sandiford@arm.com Cc: "juzhe.zhong\@rivai.ai" , gcc-patches , linkw , krebbel Subject: Re: [PATCH V3] VECT: Support loop len control on EXTRACT_LAST vectorization References: <20230811063817.491547-1-juzhe.zhong@rivai.ai> <0CF24057688529E6+2023081115284214396319@rivai.ai> Date: Fri, 11 Aug 2023 14:23:02 +0100 In-Reply-To: (Richard Biener's message of "Fri, 11 Aug 2023 11:10:22 +0000 (UTC)") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-19.9 required=5.0 tests=BAYES_00,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Richard Biener writes: > On Fri, 11 Aug 2023, juzhe.zhong@rivai.ai wrote: > >> Hi, Richi. >> >> > 1. Target is using loop MASK as the partial vector loop control. >> >> I don't think it checks for this? >> >> I am not sure whether I understand EXTRACT_LAST correctly. >> But if target doesn't use loop MASK for partial vector loop control, how does target use EXTRACT_LAST? >> Since EXTRACT_LAST is always extracting the last element of the vector according to MASK operand. >> >> > But we don't really know this at this point? The only thing we know >> > is that nothing set LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P to false. >> >> Yes. So I am try to use 'get_len_load_store' to check whether target support LEN loop control. >> >> Well, I admit it's not a good idea. >> >> >> > I think it should work to change the direct_internal_fn_supported_p >> > check for IFN_EXTRACT_LAST to a "poitive" one guarding >> >> > gcc_assert (ncopies == 1 && !slp_node); >> > vect_record_loop_mask (loop_vinfo, >> > &LOOP_VINFO_MASKS (loop_vinfo), >> > 1, vectype, NULL); >> >> > and in the else branch check for VEC_EXTRACT support and if present >> > record a loop len. Just in this case this particular order would >> > be important. >> >> Do you mean change the codes as follows :? >> >> - if (!direct_internal_fn_supported_p (IFN_EXTRACT_LAST, vectype, >> - OPTIMIZE_FOR_SPEED)) >> - { >> - if (dump_enabled_p ()) >> - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, >> - "can't operate on partial vectors " >> - "because the target doesn't support extract " >> - "last reduction.\n"); >> - LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) = false; >> - } >> - else if (slp_node) >> if (slp_node) >> { >> if (dump_enabled_p ()) >> dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, >> "can't operate on partial vectors " >> "because an SLP statement is live after " >> "the loop.\n"); >> LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) = false; >> } >> else if (ncopies > 1) >> { >> if (dump_enabled_p ()) >> dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, >> "can't operate on partial vectors " >> "because ncopies is greater than 1.\n"); >> LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) = false; >> } >> else >> { >> gcc_assert (ncopies == 1 && !slp_node); >> if (direct_internal_fn_supported_p (IFN_EXTRACT_LAST, vectype, >> OPTIMIZE_FOR_SPEED)) >> vect_record_loop_mask (loop_vinfo, >> &LOOP_VINFO_MASKS (loop_vinfo), >> 1, vectype, NULL); >> else > > check here the target supports VEC_EXTRACT > >> vect_record_loop_len (loop_vinfo, >> &LOOP_VINFO_LENS (loop_vinfo), >> 1, vectype, 1); > > else set LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P to false with a > diagnostic. I agree with all this FWIW. That is, the check should be based on .VEC_EXTRACT alone, but .EXTRACT_LAST should take priority (not least because SVE provides both .VEC_EXTRACT and .EXTRACT_LAST). Thanks, Richard