From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id E1CFC3857816; Fri, 4 Sep 2020 09:18:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E1CFC3857816 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08491spI128480; Fri, 4 Sep 2020 05:18:58 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33bjk80edq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Sep 2020 05:18:58 -0400 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08492M1t129259; Fri, 4 Sep 2020 05:18:58 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 33bjk80ed7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Sep 2020 05:18:57 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0849Bpkg000649; Fri, 4 Sep 2020 09:18:56 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 337en86q8t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Sep 2020 09:18:56 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0849Irv317564092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Sep 2020 09:18:53 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B54D611C058; Fri, 4 Sep 2020 09:18:53 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2B73011C050; Fri, 4 Sep 2020 09:18:51 +0000 (GMT) Received: from luoxhus-MacBook-Pro.local (unknown [9.200.62.8]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 4 Sep 2020 09:18:50 +0000 (GMT) Subject: Re: [PATCH] rs6000: Expand vec_insert in expander instead of gimple [PR79251] To: Richard Biener Cc: GCC Patches , David Edelsohn , Bill Schmidt , linkw@gcc.gnu.org, Segher Boessenkool References: <20200831090647.152432-1-luoxhu@linux.ibm.com> <20200831170414.GJ28786@gate.crashing.org> <3aec8b6f-8cf5-bd48-eb4e-c7b82e88dcd7@linux.ibm.com> <53017f5c-d81b-6fe2-6c5d-1496249313f1@linux.ibm.com> <599b6eff-42fc-82ef-c822-f3502997798a@linux.ibm.com> From: luoxhu Message-ID: Date: Fri, 4 Sep 2020 17:18:49 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-04_05:2020-09-04, 2020-09-04 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 impostorscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 suspectscore=0 adultscore=0 mlxscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009040079 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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: Fri, 04 Sep 2020 09:19:00 -0000 On 2020/9/4 15:23, Richard Biener wrote: > On Fri, Sep 4, 2020 at 9:19 AM Richard Biener > wrote: >> >> On Fri, Sep 4, 2020 at 8:38 AM luoxhu wrote: >>> >>> >>> >>> On 2020/9/4 14:16, luoxhu via Gcc-patches wrote: >>>> Hi, >>>> >>>> >>>> Yes, I checked and found that both vec_set and vec_extract doesn't support >>>> variable index for most targets, store_bit_field_1 and extract_bit_field_1 >>>> would only consider use optabs when index is integer value. Anyway, it >>>> shouldn't be hard to extend depending on target requirements. >>>> >>>> Another problem is v[n&3]=i and vec_insert(v, i, n) are generating with >>>> different gimple code: >>>> >>>> { >>>> _1 = n & 3; >>>> VIEW_CONVERT_EXPR(v1)[_1] = i; >>>> } >>>> >>>> vs: >>>> >>>> { >>>> __vector signed int v1; >>>> __vector signed int D.3192; >>>> long unsigned int _1; >>>> long unsigned int _2; >>>> int * _3; >>>> >>>> [local count: 1073741824]: >>>> D.3192 = v_4(D); >>>> _1 = n_7(D) & 3; >>>> _2 = _1 * 4; >>>> _3 = &D.3192 + _2; >>>> *_3 = i_8(D); >>>> v1_10 = D.3192; >>>> return v1_10; >>>> } >>> >>> Just realized use convert_vector_to_array_for_subscript would generate >>> "VIEW_CONVERT_EXPR(v1)[_1] = i;" before produce those instructions, >>> your confirmation and comments will be highly appreciated... Thanks in >>> advance. :) >> >> I think what the GCC vector extensions produce is generally better >> so wherever "code generation" for vec_insert resides it should be >> adjusted to produce the same code. Same for vec_extract. > > Guess altivec.h, dispatching to __builtin_vec_insert. Wonder why it wasn't > > #define vec_insert(a,b,c) (a)[c]=(b) > > anyway, you obviously have some lowering of the builtin somewhere in rs6000.c > and thus can adjust that. > Yes, altivec.h use that style for all vector functions, not sure why. But this could be adjusted by below patch during front end parsing, which could also generate "VIEW_CONVERT_EXPR(D.3192)[_1] = i;" in gimple, then both v[n&3]=i and vec_insert(v, i, n) could use optabs in expander: diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c index 03b00738a5e..00c65311f76 100644 --- a/gcc/config/rs6000/rs6000-c.c +++ b/gcc/config/rs6000/rs6000-c.c /* Build *(((arg1_inner_type*)&(vector type){arg1})+arg2) = arg0. */ @@ -1654,15 +1656,8 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, SET_EXPR_LOCATION (stmt, loc); stmt = build1 (COMPOUND_LITERAL_EXPR, arg1_type, stmt); } - - innerptrtype = build_pointer_type (arg1_inner_type); - - stmt = build_unary_op (loc, ADDR_EXPR, stmt, 0); - stmt = convert (innerptrtype, stmt); - stmt = build_binary_op (loc, PLUS_EXPR, stmt, arg2, 1); - stmt = build_indirect_ref (loc, stmt, RO_NULL); - stmt = build2 (MODIFY_EXPR, TREE_TYPE (stmt), stmt, - convert (TREE_TYPE (stmt), arg0)); + stmt = build_array_ref (loc, stmt, arg2); + stmt = fold_build2 (MODIFY_EXPR, TREE_TYPE (arg0), stmt, arg0); stmt = build2 (COMPOUND_EXPR, arg1_type, stmt, decl); return stmt; }