From patchwork Mon Jan 24 14:45:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 50399 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D04B33858D39 for ; Mon, 24 Jan 2022 14:46:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D04B33858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1643035563; bh=xpM0N8U+23qgoNsbdrDQRpQGflszDuD9Iw1+mangs70=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=CNFEQd29OEmqmNUheEslSSJpU6btqY6mCttPaVre2tUDlwFUnjxa/WMwK6UZTXXdr ItOu4FTD6CFo8yW9z1mQKD1PrcsfakY39/zS3NwaUqLpcgCk9H5vDssQCqd8t9/TAr 9qL5Xkt12tND0eTPy4Wag88DUUO4EIMW2Urhle00= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 70B8A3858D39 for ; Mon, 24 Jan 2022 14:45:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 70B8A3858D39 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 410F61F38B; Mon, 24 Jan 2022 14:45:34 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 28ADC13BA5; Mon, 24 Jan 2022 14:45:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 9e7MCI677mG6AgAAMHmgww (envelope-from ); Mon, 24 Jan 2022 14:45:34 +0000 Date: Mon, 24 Jan 2022 15:45:33 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] Reduce multiple_of_p uses MIME-Version: 1.0 Message-Id: <20220124144534.28ADC13BA5@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Cc: richard.sandiford@arm.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" There are a few cases where we know we're dealing with (poly-)integer constants, so remove the use of multiple_of_p in those cases to make the PR100499 fix less impactful. Bootstrapped and tested on x86_64-unknown-linux-gnu. OK? Thanks, Richard. 2022-01-24 Richard Biener PR tree-optimization/100499 * tree-cfg.cc (verify_gimple_assign_ternary): Use multiple_p on poly-ints instead of multiple_of_p. * tree-ssa.cc (maybe_rewrite_mem_ref_base): Likewise. (non_rewritable_mem_ref_base): Likewise. (non_rewritable_lvalue_p): Likewise. (execute_update_addresses_taken): Likewise. --- gcc/tree-cfg.cc | 3 ++- gcc/tree-ssa.cc | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index 77178a6bf69..2340cd7cef0 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -4410,7 +4410,8 @@ verify_gimple_assign_ternary (gassign *stmt) TREE_TYPE (rhs2_type)) && multiple_p (TYPE_VECTOR_SUBPARTS (rhs1_type), TYPE_VECTOR_SUBPARTS (rhs2_type)) - && multiple_of_p (bitsizetype, rhs3, TYPE_SIZE (rhs2_type))))) + && multiple_p (wi::to_poly_offset (rhs3), + wi::to_poly_offset (TYPE_SIZE (rhs2_type)))))) { error ("not allowed type combination in %qs", code_name); debug_generic_expr (rhs1_type); diff --git a/gcc/tree-ssa.cc b/gcc/tree-ssa.cc index 613ab05d557..8fe0682981d 100644 --- a/gcc/tree-ssa.cc +++ b/gcc/tree-ssa.cc @@ -1417,8 +1417,8 @@ maybe_rewrite_mem_ref_base (tree *tp, bitmap suitable_for_renaming) if (TREE_CODE (TREE_TYPE (sym)) == VECTOR_TYPE && useless_type_conversion_p (TREE_TYPE (*tp), TREE_TYPE (TREE_TYPE (sym))) - && multiple_of_p (sizetype, TREE_OPERAND (*tp, 1), - TYPE_SIZE_UNIT (TREE_TYPE (*tp)))) + && multiple_p (mem_ref_offset (*tp), + wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (*tp))))) { *tp = build3 (BIT_FIELD_REF, TREE_TYPE (*tp), sym, TYPE_SIZE (TREE_TYPE (*tp)), @@ -1504,8 +1504,8 @@ non_rewritable_mem_ref_base (tree ref) && known_ge (mem_ref_offset (base), 0) && known_gt (wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (decl))), mem_ref_offset (base)) - && multiple_of_p (sizetype, TREE_OPERAND (base, 1), - TYPE_SIZE_UNIT (TREE_TYPE (base)))) + && multiple_p (mem_ref_offset (base), + wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (base))))) return NULL_TREE; /* For same sizes and zero offset we can use a VIEW_CONVERT_EXPR. */ if (integer_zerop (TREE_OPERAND (base, 1)) @@ -1596,8 +1596,8 @@ non_rewritable_lvalue_p (tree lhs) && known_ge (mem_ref_offset (lhs), 0) && known_gt (wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (decl))), mem_ref_offset (lhs)) - && multiple_of_p (sizetype, TREE_OPERAND (lhs, 1), - TYPE_SIZE_UNIT (TREE_TYPE (lhs))) + && multiple_p (mem_ref_offset (lhs), + wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (lhs)))) && known_ge (wi::to_poly_offset (TYPE_SIZE (TREE_TYPE (decl))), wi::to_poly_offset (TYPE_SIZE (TREE_TYPE (lhs))))) { @@ -1969,9 +1969,9 @@ execute_update_addresses_taken (void) && known_gt (wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (sym))), mem_ref_offset (lhs)) - && multiple_of_p (sizetype, - TREE_OPERAND (lhs, 1), - TYPE_SIZE_UNIT (TREE_TYPE (lhs)))) + && multiple_p (mem_ref_offset (lhs), + wi::to_poly_offset + (TYPE_SIZE_UNIT (TREE_TYPE (lhs))))) { tree val = gimple_assign_rhs1 (stmt); if (! types_compatible_p (TREE_TYPE (val),