From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 21DF7386F458; Tue, 1 Sep 2020 14:03:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 21DF7386F458 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=segher@kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 081E2xsZ019352; Tue, 1 Sep 2020 09:02:59 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 081E2xHY019351; Tue, 1 Sep 2020 09:02:59 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Tue, 1 Sep 2020 09:02:59 -0500 From: Segher Boessenkool To: luoxhu Cc: gcc-patches@gcc.gnu.org, dje.gcc@gmail.com, wschmidt@linux.ibm.com, guojiufu@linux.ibm.com, linkw@gcc.gnu.org Subject: Re: [PATCH] rs6000: Expand vec_insert in expander instead of gimple [PR79251] Message-ID: <20200901140259.GO28786@gate.crashing.org> References: <20200831090647.152432-1-luoxhu@linux.ibm.com> <20200831170414.GJ28786@gate.crashing.org> <3aec8b6f-8cf5-bd48-eb4e-c7b82e88dcd7@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3aec8b6f-8cf5-bd48-eb4e-c7b82e88dcd7@linux.ibm.com> User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Tue, 01 Sep 2020 14:03:01 -0000 On Tue, Sep 01, 2020 at 04:09:53PM +0800, luoxhu wrote: > On 2020/9/1 01:04, Segher Boessenkool wrote: > > For v a V4SI, x a SI, j some int, what do we generate for > > v[j&3] = x; > > ? > > This should be exactly the same as we generate for > > vec_insert(x, v, j); > > (the builtin does a modulo 4 automatically). > > No, even with my patch "stxv 34,-16(1);stwx 5,9,6;lxv 34,-16(1)" generated currently. I think you should solve the problem in the generic case, then, since it is (presumably) much more frequent. > Is it feasible and acceptable to expand some kind of pattern in expander directly without > builtin transition? I don't understand what you mean? > I borrowed some of implementation from vec_extract. For vec_extract, the issue also exists: > > source: gimple: expand: asm: > 1) i = vec_extract (v, n); => i = __builtin_vec_ext_v4si (v, n); => {r120:SI=unspec[r118:V4SI,r119:DI] 134;...} => slwi 9,6,2 vextuwrx 3,9,2 > 2) i = vec_extract (v, 3); => i = __builtin_vec_ext_v4si (v, 3); => {r120:SI=vec_select(r118:V4SI,parallel)...} => li 9,12 vextuwrx 3,9,2 > 3) i = v[n%4]; => _1 = n & 3; i = VIEW_CONVERT_EXPR(v)[_1]; => ... => stxv 34,-16(1);addi 9,1,-16; rldic 5,5,2,60; lwax 3,9,5 > 4) i = v[3]; => i = BIT_FIELD_REF ; => {r120:SI=vec_select(r118:V4SI,parallel)...} => li 9,12; vextuwrx 3,9,2 > > Case 3) also couldn't handle the similar usage, and case 4) doesn't generate builtin as expected, > it just expand to vec_select by coincidence. So does this mean both vec_insert and vec_extract > and all other similar vector builtins should use IFN as suggested by Richard Biener, to match the > pattern in gimple and expand both constant and variable index in expander? Will this also be > beneficial for other targets except power? Or we should do that gradually after this patch > approved as it seems another independent issue? Thanks:) I don't think we should do that at all? IFNs just complicate everything, there is no added value here: this is just data movement! We need to avoid the data aliasing some generic way. Segher