From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 9B9333858C54 for ; Wed, 6 Apr 2022 10:25:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9B9333858C54 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 7ED421F38A; Wed, 6 Apr 2022 10:25:04 +0000 (UTC) Received: from murzim.suse.de (murzim.suse.de [10.160.4.192]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 7887FA3B87; Wed, 6 Apr 2022 10:25:04 +0000 (UTC) Date: Wed, 6 Apr 2022 12:25:04 +0200 (CEST) From: Richard Biener To: Jakub Jelinek cc: Richard Biener via Gcc-patches , richard.sandiford@arm.com Subject: Re: [PATCH] gimple.cc: Adjust gimple_call_builtin_p and gimple_call_combined_fn [PR105150] In-Reply-To: Message-ID: <57s7s321-3p1-2qn7-o6q9-o3358p785190@fhfr.qr> References: <29rro087-321q-6r5r-95qs-9qn7s3qp641r@fhfr.qr> <34o4435-1432-676-rpn1-73q86o754230@fhfr.qr> <174r195-933o-p944-rp-6oo5npp7so3@fhfr.qr> MIME-Version: 1.0 X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Wed, 06 Apr 2022 10:25:07 -0000 On Wed, 6 Apr 2022, Jakub Jelinek wrote: > On Wed, Apr 06, 2022 at 11:52:23AM +0200, Richard Biener wrote: > > On Wed, 6 Apr 2022, Jakub Jelinek wrote: > > > > > On Wed, Apr 06, 2022 at 09:41:44AM +0100, Richard Sandiford wrote: > > > > But it seems like the magic incantation to detect “real” built-in > > > > function calls is getting longer and longer. Can we not abstract this > > > > in a single place rather than have to repeat the same long sequence in > > > > multiple places? > > > > > > I've already committed it, so it can be only dealt with an incremental > > > patch. > > > One possibility is to do it inside of > > > gimple_builtin_call_types_compatible_p, after the assert do that: > > > if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) > > > if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl))) > > > fndecl = decl; > > > but we then lose the theoretical possibility of comparing against the > > > actual user declaration. Though I guess in the > > > gimple-fold.cc > > > gimple-low.cc > > > gimple-match-head.cc > > > calls to that function we also want this rather than what they do currently. > > > > Yes, I think it would be clearer to pass a BUILT_IN_* code to > > gimple_builtin_call_types_compatible_p and no decl and simply return > > false if we cannot get out hands at the "proper" decl from > > builtin_decl_explicit ... > > That would mean we wouldn't verify the md or FE builtins anymore > and we would need to check for BUILT_IN_NORMAL in every caller (right now > we do that only in some of them). > > Here is what I had in mind (untested so far): Yes, that works as well for me. Richard. > 2022-04-06 Jakub Jelinek > > PR tree-optimization/105150 > * gimple.cc (gimple_builtin_call_types_compatible_p): Use > builtin_decl_explicit here... > (gimple_call_builtin_p, gimple_call_combined_fn): ... rather than > here. > > --- gcc/gimple.cc.jj 2022-04-06 10:07:23.043064595 +0200 > +++ gcc/gimple.cc 2022-04-06 11:31:31.704255242 +0200 > @@ -2788,6 +2788,10 @@ gimple_builtin_call_types_compatible_p ( > { > gcc_checking_assert (DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN); > > + if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) > + if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl))) > + fndecl = decl; > + > tree ret = gimple_call_lhs (stmt); > if (ret > && !useless_type_conversion_p (TREE_TYPE (ret), > @@ -2841,12 +2845,7 @@ gimple_call_builtin_p (const gimple *stm > if (is_gimple_call (stmt) > && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE > && DECL_BUILT_IN_CLASS (fndecl) != NOT_BUILT_IN) > - { > - if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) > - if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl))) > - fndecl = decl; > - return gimple_builtin_call_types_compatible_p (stmt, fndecl); > - } > + return gimple_builtin_call_types_compatible_p (stmt, fndecl); > return false; > } > > @@ -2859,12 +2858,7 @@ gimple_call_builtin_p (const gimple *stm > if (is_gimple_call (stmt) > && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE > && DECL_BUILT_IN_CLASS (fndecl) == klass) > - { > - if (klass == BUILT_IN_NORMAL) > - if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl))) > - fndecl = decl; > - return gimple_builtin_call_types_compatible_p (stmt, fndecl); > - } > + return gimple_builtin_call_types_compatible_p (stmt, fndecl); > return false; > } > > @@ -2877,11 +2871,7 @@ gimple_call_builtin_p (const gimple *stm > if (is_gimple_call (stmt) > && (fndecl = gimple_call_fndecl (stmt)) != NULL_TREE > && fndecl_built_in_p (fndecl, code)) > - { > - if (tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl))) > - fndecl = decl; > - return gimple_builtin_call_types_compatible_p (stmt, fndecl); > - } > + return gimple_builtin_call_types_compatible_p (stmt, fndecl); > return false; > } > > @@ -2898,14 +2888,10 @@ gimple_call_combined_fn (const gimple *s > return as_combined_fn (gimple_call_internal_fn (call)); > > tree fndecl = gimple_call_fndecl (stmt); > - if (fndecl && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)) > - { > - tree decl = builtin_decl_explicit (DECL_FUNCTION_CODE (fndecl)); > - if (!decl) > - decl = fndecl; > - if (gimple_builtin_call_types_compatible_p (stmt, decl)) > - return as_combined_fn (DECL_FUNCTION_CODE (fndecl)); > - } > + if (fndecl > + && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL) > + && gimple_builtin_call_types_compatible_p (stmt, fndecl)) > + return as_combined_fn (DECL_FUNCTION_CODE (fndecl)); > } > return CFN_LAST; > } > > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Ivo Totev; HRB 36809 (AG Nuernberg)