Message ID | 58acc8c2-b6a4-e9ec-c89b-ad841cf759ed@linux.ibm.com |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp808926wro; Fri, 2 Sep 2022 09:22:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR5kKtKXKtQwgkHqXQ80AADy8T1qxOPwG830L9DSpZERpLpti5Gq0wiVrtaww+sD7Ay1Nvsg X-Received: by 2002:a17:906:58d6:b0:733:77c:5ed1 with SMTP id e22-20020a17090658d600b00733077c5ed1mr28162273ejs.454.1662135777065; Fri, 02 Sep 2022 09:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662135777; cv=none; d=google.com; s=arc-20160816; b=cZAjmDz+pR4HpviaOD4RrH0wTVUJeV291YBr2ZUiJQiNjcrMJixxA57spEzkV3kGxn n1kVBT5SHKENl1kj3k2DINPQHwxWoJh4jvcYrhBBMiQULFzkyLhredPa/SGnxsLwgJdH 3UqscTSRnkwFfU0QSUXIdEdPwsgJ7f+lkhI7d6d9bQSAYeRTXw4QLsfhH28mXTxnOmjt VJtOiuGRAepp0So4PtTsFTtXgM6DdWs3nXB5U9CxnKzEMlnI8VqnMDFERfDHcQe3eDpl 3Nz2+SG4x8My6Fc0wLRhbeCmkyvB3M07xMfHA+2qDZgP6C3Lz3v22iMme1QI92Fd44+4 raeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:subject:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=qjK/cOJNfewuODjwOwWt1RquPVjCfdP+lj2GBhbOYcg=; b=U5vvu2at5mH3ceDA1Omo2c3LNQ3NE76T02fAqf9AJpEf2ATjsgOZyRrVL6SHkkPEal 2/eXaMewkOM2+20QsMJQwfap3gOEB9sKLjUaFYWG918ATzCWrenu9yg4MWCoeABkbhZl MsGJXcjHULrSHQhjcIf0pD1RctGwcmMbxCapww8C+q5HAkRFUC0QiIZS5rbyfIoUghSW W6CcyCZUpY+vtnVwFtEwL2haR2TRhaM5Zrx+HWSUBMolymYYSoWm1nyBVncYEN1E6S7T nTD1SG75eCRj8o2AhCV1FmMfg4y7CHQGUsmmKxF9VmNGd1tzrgpmG3voUIvjpWhCiTVS mdoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=SBE48um7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id hg2-20020a1709072cc200b00741a089d32fsi1965573ejc.634.2022.09.02.09.22.56 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 09:22:57 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=SBE48um7; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D9D82385828B for <ouuuleilei@gmail.com>; Fri, 2 Sep 2022 16:22:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9D82385828B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662135775; bh=qjK/cOJNfewuODjwOwWt1RquPVjCfdP+lj2GBhbOYcg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=SBE48um7irJqHbPWMps8nX6DzpUpeNADG6htPhCXcpwbCclN0VwNI/qMT5yAte6IU 6OQfLqw90VC+YG9qBChdp2Qa1cYlCRVtKzThCgrJvnlAE3Rehw7vPprSLpfZqtVFeL 3fpHuclFECbHyCsyXNfGchNfK44kECXSDaumVmfU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 0DBFE3858C53 for <gcc-patches@gcc.gnu.org>; Fri, 2 Sep 2022 16:22:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0DBFE3858C53 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 282FI5UW005141; Fri, 2 Sep 2022 16:22:11 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3jbmbthyjh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Sep 2022 16:22:10 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 282G79xI019186; Fri, 2 Sep 2022 16:22:09 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma01dal.us.ibm.com with ESMTP id 3j7awak8gu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Sep 2022 16:22:09 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 282GM85513435584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Sep 2022 16:22:08 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D9056E052; Fri, 2 Sep 2022 16:22:08 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0AC4C6E04E; Fri, 2 Sep 2022 16:22:07 +0000 (GMT) Received: from [9.160.4.32] (unknown [9.160.4.32]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 2 Sep 2022 16:22:07 +0000 (GMT) Message-ID: <58acc8c2-b6a4-e9ec-c89b-ad841cf759ed@linux.ibm.com> Date: Fri, 2 Sep 2022 11:22:07 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Content-Language: en-US To: Segher Boessenkool <segher@kernel.crashing.org>, "Kewen.Lin" <linkw@linux.ibm.com> Subject: [PATCH] rs6000: Use NO_EXPR to cast to MMA pointer types Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: KWRMIwT67-E4qdnJpDFONzIDZCISCEww X-Proofpoint-ORIG-GUID: KWRMIwT67-E4qdnJpDFONzIDZCISCEww X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-09-02_04,2022-08-31_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 impostorscore=0 mlxlogscore=951 spamscore=0 lowpriorityscore=0 suspectscore=0 priorityscore=1501 phishscore=0 mlxscore=0 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209020075 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Peter Bergner via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Peter Bergner <bergner@linux.ibm.com> Cc: GCC Patches <gcc-patches@gcc.gnu.org> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742875684503698792?= X-GMAIL-MSGID: =?utf-8?q?1742875684503698792?= |
Series |
rs6000: Use NO_EXPR to cast to MMA pointer types
|
|
Commit Message
Peter Bergner
Sept. 2, 2022, 4:22 p.m. UTC
When we cast pointers to our opaque MMA pointers, use NOP_EXPR rather than VIEW_CONVERT_EXPR. This passed bootstrap and regtesting on powerpc64le-linux with no regressions. Ok for trunk? I think this is just a cleanup and not a correctness thing, so I'm assuming a backport isn't needed? Or maybe we do to make other potential backports easier? I'm fine either way. Peter gcc/ * config/rs6000/rs6000-builtin.cc (rs6000_gimple_fold_mma_builtin): Use NOP_EXPR for MMA pointer casting.
Comments
Hi! On Fri, Sep 02, 2022 at 11:22:07AM -0500, Peter Bergner wrote: > When we cast pointers to our opaque MMA pointers, use NOP_EXPR rather > than VIEW_CONVERT_EXPR. > I think this is just a cleanup and not a correctness thing, so I'm assuming a > backport isn't needed? Or maybe we do to make other potential backports easier? > I'm fine either way. I wouldn't worry about backports. If it does make other backports easier in the future, we can decide to backport this *then*. Okay for trunk. Thanks! (Did you also look at non-MMA VIEW_CONVERT_EXPR uses btw?) Segher
On 9/2/22 11:31 AM, Segher Boessenkool wrote: > I wouldn't worry about backports. If it does make other backports > easier in the future, we can decide to backport this *then*. Ok. > (Did you also look at non-MMA VIEW_CONVERT_EXPR uses btw?) I did. It seemed they were all related to pointers to vectors and I remember you mentioning that as one of the reasons for using VIEW_CONVERT_EXPR over NOP_EXPR, so I left them alone to be safe. > Okay for trunk. Thanks! Ok, pushed to trunk. Thanks! Peter
On Fri, Sep 02, 2022 at 12:02:54PM -0500, Peter Bergner wrote: > On 9/2/22 11:31 AM, Segher Boessenkool wrote: > > (Did you also look at non-MMA VIEW_CONVERT_EXPR uses btw?) > > I did. It seemed they were all related to pointers to vectors and I remember > you mentioning that as one of the reasons for using VIEW_CONVERT_EXPR over > NOP_EXPR, so I left them alone to be safe. Huh? I have no idea what you mean here. Casting from one pointer type to another never needs it. Casting from a scalar integer type to a pointer type not either AFAIKi. But I am not a Gimple expert, all this might be wrong, it isn't documented anywbere :-( Segher
On 9/2/22 12:23 PM, Segher Boessenkool wrote: > On Fri, Sep 02, 2022 at 12:02:54PM -0500, Peter Bergner wrote: >> On 9/2/22 11:31 AM, Segher Boessenkool wrote: >>> (Did you also look at non-MMA VIEW_CONVERT_EXPR uses btw?) >> >> I did. It seemed they were all related to pointers to vectors and I remember >> you mentioning that as one of the reasons for using VIEW_CONVERT_EXPR over >> NOP_EXPR, so I left them alone to be safe. > > Huh? I have no idea what you mean here. > > Casting from one pointer type to another never needs it. Casting from a > scalar integer type to a pointer type not either AFAIKi. But I am not a > Gimple expert, all this might be wrong, it isn't documented anywbere :-( Ah, then I misunderstood you and didn't pick up on the non-pointer thing. ...which just goes to show I'm not an expert and someone else should look at those uses. :-) Peter
On Fri, Sep 2, 2022 at 7:24 PM Segher Boessenkool <segher@kernel.crashing.org> wrote: > > On Fri, Sep 02, 2022 at 12:02:54PM -0500, Peter Bergner wrote: > > On 9/2/22 11:31 AM, Segher Boessenkool wrote: > > > (Did you also look at non-MMA VIEW_CONVERT_EXPR uses btw?) > > > > I did. It seemed they were all related to pointers to vectors and I remember > > you mentioning that as one of the reasons for using VIEW_CONVERT_EXPR over > > NOP_EXPR, so I left them alone to be safe. > > Huh? I have no idea what you mean here. > > Casting from one pointer type to another never needs it. Casting from a > scalar integer type to a pointer type not either AFAIKi. But I am not a > Gimple expert, all this might be wrong, it isn't documented anywbere :-( NOP_EXPR is for conversions between types with the same kind (and pointer-to-integer and integer-to-pointer conversions when pointer and integer are of the same size). When used on vectors it converts the vector elements. When you want to re-interpret V4SI as V4SF you need VIEW_CONVERT_EXPR (bit_cast), likewise V4SI interpreted as V16QI needs that. Think of VIEW_CONVERT as bit_cast and NOP_EXPR as conversion. Of course for some conversions (like unsigned int to int) you can also use a VIEW_CONVERT since it's semantically the same. In those cases we canonicalize to NOP_EXPR via folding. Richard. > > > Segher
On Mon, Sep 05, 2022 at 11:25:21AM +0200, Richard Biener wrote: > On Fri, Sep 2, 2022 at 7:24 PM Segher Boessenkool > <segher@kernel.crashing.org> wrote: > > On Fri, Sep 02, 2022 at 12:02:54PM -0500, Peter Bergner wrote: > > > On 9/2/22 11:31 AM, Segher Boessenkool wrote: > > > > (Did you also look at non-MMA VIEW_CONVERT_EXPR uses btw?) > > > > > > I did. It seemed they were all related to pointers to vectors and I remember > > > you mentioning that as one of the reasons for using VIEW_CONVERT_EXPR over > > > NOP_EXPR, so I left them alone to be safe. > > > > Huh? I have no idea what you mean here. > > > > Casting from one pointer type to another never needs it. Casting from a > > scalar integer type to a pointer type not either AFAIKi. But I am not a > > Gimple expert, all this might be wrong, it isn't documented anywbere :-( > > NOP_EXPR is for conversions between types with the same kind > (and pointer-to-integer and integer-to-pointer > conversions when pointer and integer are of the same size). > When used on vectors it converts the vector elements. When you want to > re-interpret V4SI as V4SF you need VIEW_CONVERT_EXPR (bit_cast), > likewise V4SI interpreted as V16QI needs that. > > Think of VIEW_CONVERT as bit_cast and NOP_EXPR as conversion. > Of course for some conversions (like unsigned int to int) you can also > use a VIEW_CONVERT since it's semantically the same. In those cases > we canonicalize to NOP_EXPR via folding. Thanks for the explanation! About that last point... You say VIEW_CONVERT_EXPR is folded to NOP_EXPR where possible. Does that happen in all cases / can we depend on that? So that in target code like what started this thread the only real difference is documentation of intent? (Which never is unimportant of course!) Segher
> Am 05.09.2022 um 16:53 schrieb Segher Boessenkool <segher@kernel.crashing.org>: > > On Mon, Sep 05, 2022 at 11:25:21AM +0200, Richard Biener wrote: >>> On Fri, Sep 2, 2022 at 7:24 PM Segher Boessenkool >>> <segher@kernel.crashing.org> wrote: >>> On Fri, Sep 02, 2022 at 12:02:54PM -0500, Peter Bergner wrote: >>>> On 9/2/22 11:31 AM, Segher Boessenkool wrote: >>>>> (Did you also look at non-MMA VIEW_CONVERT_EXPR uses btw?) >>>> >>>> I did. It seemed they were all related to pointers to vectors and I remember >>>> you mentioning that as one of the reasons for using VIEW_CONVERT_EXPR over >>>> NOP_EXPR, so I left them alone to be safe. >>> >>> Huh? I have no idea what you mean here. >>> >>> Casting from one pointer type to another never needs it. Casting from a >>> scalar integer type to a pointer type not either AFAIKi. But I am not a >>> Gimple expert, all this might be wrong, it isn't documented anywbere :-( >> >> NOP_EXPR is for conversions between types with the same kind >> (and pointer-to-integer and integer-to-pointer >> conversions when pointer and integer are of the same size). >> When used on vectors it converts the vector elements. When you want to >> re-interpret V4SI as V4SF you need VIEW_CONVERT_EXPR (bit_cast), >> likewise V4SI interpreted as V16QI needs that. >> >> Think of VIEW_CONVERT as bit_cast and NOP_EXPR as conversion. >> Of course for some conversions (like unsigned int to int) you can also >> use a VIEW_CONVERT since it's semantically the same. In those cases >> we canonicalize to NOP_EXPR via folding. > > Thanks for the explanation! > > About that last point... You say VIEW_CONVERT_EXPR is folded to > NOP_EXPR where possible. Does that happen in all cases / can we depend > on that? So that in target code like what started this thread the only > real difference is documentation of intent? (Which never is unimportant > of course!) You should be able to depend on that, yes. Richard > > > Segher
diff --git a/gcc/config/rs6000/rs6000-builtin.cc b/gcc/config/rs6000/rs6000-builtin.cc index e6948b9abb7..0d8be996f4e 100644 --- a/gcc/config/rs6000/rs6000-builtin.cc +++ b/gcc/config/rs6000/rs6000-builtin.cc @@ -1101,7 +1101,7 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi, || (fncode == RS6000_BIF_DISASSEMBLE_PAIR_V && TREE_TYPE (TREE_TYPE (dst_ptr)) == vector_pair_type_node)) { - tree dst = build_simple_mem_ref (build1 (VIEW_CONVERT_EXPR, + tree dst = build_simple_mem_ref (build1 (NOP_EXPR, src_type, dst_ptr)); gimplify_assign (dst, src, &new_seq); pop_gimplify_context (NULL); @@ -1125,7 +1125,7 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi, = rs6000_builtin_decls[rs6000_builtin_info[fncode].assoc_bif]; tree dst_type = build_pointer_type_for_mode (unsigned_V16QI_type_node, ptr_mode, true); - tree dst_base = build1 (VIEW_CONVERT_EXPR, dst_type, dst_ptr); + tree dst_base = build1 (NOP_EXPR, dst_type, dst_ptr); for (unsigned i = 0; i < nvec; i++) { unsigned index = WORDS_BIG_ENDIAN ? i : nvec - 1 - i; @@ -1151,7 +1151,7 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi, tree ptr = gimple_call_arg (stmt, 1); tree lhs = gimple_call_lhs (stmt); if (TREE_TYPE (TREE_TYPE (ptr)) != vector_pair_type_node) - ptr = build1 (VIEW_CONVERT_EXPR, + ptr = build1 (NOP_EXPR, build_pointer_type (vector_pair_type_node), ptr); tree mem = build_simple_mem_ref (build2 (POINTER_PLUS_EXPR, TREE_TYPE (ptr), ptr, offset)); @@ -1168,7 +1168,7 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi, tree offset = gimple_call_arg (stmt, 1); tree ptr = gimple_call_arg (stmt, 2); if (TREE_TYPE (TREE_TYPE (ptr)) != vector_pair_type_node) - ptr = build1 (VIEW_CONVERT_EXPR, + ptr = build1 (NOP_EXPR, build_pointer_type (vector_pair_type_node), ptr); tree mem = build_simple_mem_ref (build2 (POINTER_PLUS_EXPR, TREE_TYPE (ptr), ptr, offset));