From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id C6D4A3858D28 for ; Wed, 3 May 2023 11:55:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C6D4A3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D573822716; Wed, 3 May 2023 11:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1683114958; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=F/m/bJphqVU9PgsY/p3Ie23RDNDu3Uy9L06XiyqkaVs=; b=jUOcWTKV7ezsxCGh7bBVNg1XXaiNE3npz9ms1jGPvsgrrvuxQw8/PF3nVqUv1KXX51Llz9 gXFJ/r37p0R9HMAExrprDphKd4bJTEpO9MgFuOYvBqed9TRvQtmOaNrImum31Jn2osTpwq 0OqacRuDDapBhyE8ecw5q7jlUVtI3ng= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1683114958; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=F/m/bJphqVU9PgsY/p3Ie23RDNDu3Uy9L06XiyqkaVs=; b=EvSREBLp4HHaIsxNwF0l3d5LwVCeOwHmx0m9zyS8aelIC8UWO7fNad07NSqxFVVQbSoIQC 2N6zhJNnyRreRUBw== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (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 BEC3F2C141; Wed, 3 May 2023 11:55:58 +0000 (UTC) Date: Wed, 3 May 2023 11:55:58 +0000 (UTC) From: Richard Biener To: "Andre Vieira (lists)" cc: Richard Biener , Richard Sandiford , "gcc-patches@gcc.gnu.org" Subject: Re: [PATCH 1/3] Refactor to allow internal_fn's In-Reply-To: Message-ID: References: <51ce8969-3130-452e-092e-f9d91eff2dad@arm.com> User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.0 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, 28 Apr 2023, Andre Vieira (lists) wrote: > Hi, > > I'm posting the patches separately now with ChangeLogs. > > I made the suggested changes and tried to simplify the code a bit further. > Where internal to tree-vect-stmts I changed most functions to use code_helper > to avoid having to check at places we didn't need to. I was trying to simplify > things further by also modifying supportable_half_widening_operation and > supportable_convert_operation but the result of that was that I ended up > moving the code to cast to tree code inside them rather than at the call site > and it didn't look simpler, so I left those. Though if we did make those > changes we'd no longer need to keep around the tc1 variable in > vectorizable_conversion... Let me know what you think. I see that - else if (CONVERT_EXPR_CODE_P (code) + else if (CONVERT_EXPR_CODE_P (code.safe_as_tree_code ()) is convenient (as much as I dislike safe_as_tree_code). Isn't the following - if (!CONVERT_EXPR_CODE_P (code)) + if (!CONVERT_EXPR_CODE_P ((tree_code) code)) return false; then wrong? In other places you added an assert - I assume that we might want to checking assert in the cast operators? (those were added mainly for convenience, maybe we want as_a <>, etc. here - not sure if those will play well with enums though). Just suggestions for eventual followups in this area. +inline enum tree_code +code_helper::safe_as_tree_code () const +{ + return is_tree_code () ? (tree_code) *this : MAX_TREE_CODES; +} + +inline combined_fn +code_helper::safe_as_fn_code () const { + return is_fn_code () ? (combined_fn) *this : CFN_LAST; +} + newline after the last 'const'. Can you place a comment before these to explain their intended use? Aka give the case the code isn't the desired kind a safe value? The patch is OK with just the last bit fixed. Thanks, Richard. > gcc/ChangeLog: > > 2023-04-28 Andre Vieira > Joel Hutton > > * tree-vect-patterns.cc (vect_gimple_build): New Function. > (vect_recog_widen_op_pattern): Refactor to use code_helper. > * tree-vect-stmts.cc (vect_gen_widened_results_half): Likewise. > (vect_create_vectorized_demotion_stmts): Likewise. > (vect_create_vectorized_promotion_stmts): Likewise. > (vect_create_half_widening_stmts): Likewise. > (vectorizable_conversion): Likewise. > (vectorizable_call): Likewise. > (supportable_widening_operation): Likewise. > (supportable_narrowing_operation): Likewise. > (simple_integer_narrowing): Likewise. > * tree-vectorizer.h (supportable_widening_operation): Likewise. > (supportable_narrowing_operation): Likewise. > (vect_gimple_build): New function prototype. > * tree.h (code_helper::safe_as_tree_code): New function. > (code_helper::safe_as_fn_code): New function. > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)