From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 53E9A3858C53 for ; Fri, 21 Jul 2023 02:19:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53E9A3858C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 36L17BoO028527; Fri, 21 Jul 2023 02:19:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=MZw9PTiU+taCqyMqhX4qs1I4JCDJJ5cC8CwljAVS4es=; b=Qg9aFvx21QwdWBS36B4+GqXSEEQwDpuX2NFqWPVh7O8KIA4D+ZzHnFPfqM2jA8vdmO58 rFIljSMrRBPohSSvikoQImmS8raYSmXSDv3+clOOWFq1mx3KfNsiF8jiaO+ZoLcJy4l9 WNMiN3wb946VemCWNrS6WVqngMqb+9EYjyvFK0mJBgjE3sLBEfurRdRM5Z4A7YbWY/kW D2OL4HfXqc3NY1kd6giH6FoNs8v735MAsjpQapHARJPvJjzZKIATuvexNrS0abGX+SmY ANNeCarKeNwlNafFiB5DZkalvQ0n2WeEnf/PVpbZ4RMbGWk3KW9U19i3pY9Bj2H3ZuQL bg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rye3fbrta-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jul 2023 02:19:16 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 36L1X4mW005001; Fri, 21 Jul 2023 02:19:15 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rye3fbrsw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jul 2023 02:19:15 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 36L15kP1003394; Fri, 21 Jul 2023 02:19:14 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3rv65xtvcq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jul 2023 02:19:14 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 36L2JCGw6816422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jul 2023 02:19:12 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5ADA820043; Fri, 21 Jul 2023 02:19:12 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4E85820049; Fri, 21 Jul 2023 02:19:10 +0000 (GMT) Received: from [9.177.28.8] (unknown [9.177.28.8]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 21 Jul 2023 02:19:09 +0000 (GMT) Message-ID: <6828e9a4-a121-0e84-d516-993cc0133eab@linux.ibm.com> Date: Fri, 21 Jul 2023 10:19:08 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH 1/2] rs6000, add argument to function find_instance Content-Language: en-US To: Carl Love Cc: Peter Bergner , Segher Boessenkool , David Edelsohn , gcc-patches@gcc.gnu.org References: <949827540816a434c5bac00f0714948638c37975.camel@us.ibm.com> From: "Kewen.Lin" In-Reply-To: <949827540816a434c5bac00f0714948638c37975.camel@us.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ujSiUwIbZHo3I8ayUNnpl8qZ-qDOytbL X-Proofpoint-ORIG-GUID: M4uRHgKtj9g8yIV-twxJkTN210yWRyz8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-20_12,2023-07-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 mlxscore=0 priorityscore=1501 adultscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 malwarescore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2307210017 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 List-Id: Hi Carl, on 2023/7/18 03:19, Carl Love wrote: > > GCC maintainers: > > The rs6000 function find_instance assumes that it is called for built- > ins with only two arguments. There is no checking for the actual > number of aruguments used in the built-in. This patch adds an > additional parameter to the function call containing the number of > aruguments in the built-in. The function will now do the needed checks > for all of the arguments. > > This fix is needed for the next patch in the series that fixes the > vec_replace_unaligned built-in.c test. > > Please let me know if this patch is acceptable for mainline. Thanks. > > Carl > > > -------------------------------------------- > rs6000, add argument to function find_instance > > The function find_instance assumes it is called to check a built-in with ~~ two spaces. > only two arguments. Ths patch extends the function by adding a parameter s/Ths/This/ > specifying the number of buit-in arguments to check. s/bult-in/built-in/ > > gcc/ChangeLog: > * config/rs6000/rs6000-c.cc (find_instance): Add new parameter that > specifies the number of built-in arguments to check. > (altivec_resolve_overloaded_builtin): Update calls to find_instance > to pass the number of built-in argument to be checked. s/argument/arguments/ > --- > gcc/config/rs6000/rs6000-c.cc | 27 +++++++++++++++++++-------- > 1 file changed, 19 insertions(+), 8 deletions(-) > > diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc > index a353bca19ef..350987b851b 100644 > --- a/gcc/config/rs6000/rs6000-c.cc > +++ b/gcc/config/rs6000/rs6000-c.cc > @@ -1679,7 +1679,7 @@ tree There is one function comment here describing the meaning of each parameter, I think we should add a corresponding for NARGS, may be something like: "; and NARGS specifies the number of built-in arguments." Also we need to update the below "two"s with "NARGS". "TYPES contains an array of two types..." and "ARGS contains an array of two arguments..." since we already extend this to handle NARGS instead of two. > find_instance (bool *unsupported_builtin, ovlddata **instance, > rs6000_gen_builtins instance_code, > rs6000_gen_builtins fcode, > - tree *types, tree *args) > + tree *types, tree *args, int nargs) > { > while (*instance && (*instance)->bifid != instance_code) > *instance = (*instance)->next; > @@ -1691,17 +1691,28 @@ find_instance (bool *unsupported_builtin, ovlddata **instance, > if (!inst->fntype) > return error_mark_node; > tree fntype = rs6000_builtin_info[inst->bifid].fntype; > - tree parmtype0 = TREE_VALUE (TYPE_ARG_TYPES (fntype)); > - tree parmtype1 = TREE_VALUE (TREE_CHAIN (TYPE_ARG_TYPES (fntype))); > + tree argtype = TYPE_ARG_TYPES (fntype); > + tree parmtype; Nit: We can move "tree parmtype" into the loop (close to its only use). > + int args_compatible = true; s/int/bool/ > > - if (rs6000_builtin_type_compatible (types[0], parmtype0) > - && rs6000_builtin_type_compatible (types[1], parmtype1)) > + for (int i = 0; i { > + parmtype = TREE_VALUE (argtype); tree parmtype = TREE_VALUE (argtype); > + if (! rs6000_builtin_type_compatible (types[i], parmtype)) Nit: One unexpected(?) space after "!". > + { > + args_compatible = false; > + break; > + } > + argtype = TREE_CHAIN (argtype); > + } > + > + if (args_compatible) > + { Nit: indent issue for "{". Ok for trunk with these nits fixed. Btw, the description doesn't say how this was tested, I'm not sure if it's only tested together with "patch 2/2", but please ensure it's bootstrapped and regress-tested on BE and LE when committing. Thanks! BR, Kewen > if (rs6000_builtin_decl (inst->bifid, false) != error_mark_node > && rs6000_builtin_is_supported (inst->bifid)) > { > tree ret_type = TREE_TYPE (inst->fntype); > - return altivec_build_resolved_builtin (args, 2, fntype, ret_type, > + return altivec_build_resolved_builtin (args, nargs, fntype, ret_type, > inst->bifid, fcode); > } > else > @@ -1921,7 +1932,7 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, > instance_code = RS6000_BIF_CMPB_32; > > tree call = find_instance (&unsupported_builtin, &instance, > - instance_code, fcode, types, args); > + instance_code, fcode, types, args, nargs); > if (call != error_mark_node) > return call; > break; > @@ -1958,7 +1969,7 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl, > } > > tree call = find_instance (&unsupported_builtin, &instance, > - instance_code, fcode, types, args); > + instance_code, fcode, types, args, nargs); > if (call != error_mark_node) > return call; > break;