From patchwork Wed Apr 6 09:23:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 52667 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 0C1323857811 for ; Wed, 6 Apr 2022 09:23:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C1323857811 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1649237028; bh=AjsLEXEJdskT+HJWAN/G5ecAhnDHFM6j/ueu1l+oFPk=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=odycgmV/crPcauOP/wJBdP7DjI5o7mh3EsFqwpyKtilzcb20vTgFZsbtd0kya2MgB KxtRW/bVo4cjL+sMiJf15uRJdfHo67wx+77PSuPTNZ6hVPi6ta11MmqxEAljHyL2sz TFp0KBbw+MFS5I2tjP9ArL4df2mWH1FjFkqZ/X0g= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id D3E6F3858C52 for ; Wed, 6 Apr 2022 09:23:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D3E6F3858C52 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-out1.suse.de (Postfix) with ESMTPS id B3BDF210F5; Wed, 6 Apr 2022 09:23:17 +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 97CD3139F5; Wed, 6 Apr 2022 09:23:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GHTxIwVcTWL3BAAAMHmgww (envelope-from ); Wed, 06 Apr 2022 09:23:17 +0000 Date: Wed, 6 Apr 2022 11:23:17 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/105175 - avoid -Wvector-operation-performance MIME-Version: 1.0 Message-Id: <20220406092317.97CD3139F5@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.7 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, 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 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: msebor@redhat.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This avoids -Wvector-operation-performance diagnostics for vectorizer produced code. It's unfortunate the warning_at code in tree-vect-generic.cc needs adjustments but the diagnostic suppression code doesn't magically suppress those otherwise. Bootstrap / regtest running on x86_64-unknown-linux-gnu. Martin/David - did I miss something obvious when doing the tree-vect-generic.cc adjustment? Thanks, Richard. 2022-04-06 Richard Biener PR tree-optimization/105175 * tree-vect-stmts.cc (vectorizable_operation): Suppress -Wvector-operation-performance if using emulated vectors. * tree-vect-generic.cc (expand_vector_piecewise): Do not diagnose -Wvector-operation-performance when suppressed. (expand_vector_parallel): Likewise. (expand_vector_comparison): Likewise. (expand_vector_condition): Likewise. (lower_vec_perm): Likewise. (expand_vector_conversion): Likewise. * gcc.dg/pr105175.c: New testcase. --- gcc/testsuite/gcc.dg/pr105175.c | 16 +++++++++++++ gcc/tree-vect-generic.cc | 41 ++++++++++++++++++++++----------- gcc/tree-vect-stmts.cc | 2 ++ 3 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr105175.c diff --git a/gcc/testsuite/gcc.dg/pr105175.c b/gcc/testsuite/gcc.dg/pr105175.c new file mode 100644 index 00000000000..d8d7edb942a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr105175.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wvector-operation-performance" } */ +/* { dg-additional-options "-mno-sse" { target x86_64-*-* i?86-*-* } } */ + +enum { QEMU_MIGRATION_COOKIE_PERSISTENT = 1 }; +struct { + unsigned flags; + unsigned flagsMandatory; +} qemuMigrationCookieGetPersistent_mig; +void qemuMigrationCookieGetPersistent() +{ + qemuMigrationCookieGetPersistent_mig.flags &= /* { dg-bogus "will be expanded" } */ + QEMU_MIGRATION_COOKIE_PERSISTENT; + qemuMigrationCookieGetPersistent_mig.flagsMandatory &= + QEMU_MIGRATION_COOKIE_PERSISTENT; +} diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc index 12a553ec8be..8b7227e8b58 100644 --- a/gcc/tree-vect-generic.cc +++ b/gcc/tree-vect-generic.cc @@ -317,8 +317,11 @@ expand_vector_piecewise (gimple_stmt_iterator *gsi, elem_op_func f, int i; location_t loc = gimple_location (gsi_stmt (*gsi)); - if (nunits == 1) - /* Do not diagnose decomposing single element vectors. */ + if (nunits == 1 + || warning_suppressed_p (gsi_stmt (*gsi), + OPT_Wvector_operation_performance)) + /* Do not diagnose decomposing single element vectors or when + decomposing vectorizer produced operations. */ ; else if (ret_type || !parallel_p) warning_at (loc, OPT_Wvector_operation_performance, @@ -379,14 +382,16 @@ expand_vector_parallel (gimple_stmt_iterator *gsi, elem_op_func f, tree type, else { /* Use a single scalar operation with a mode no wider than word_mode. */ + if (!warning_suppressed_p (gsi_stmt (*gsi), + OPT_Wvector_operation_performance)) + warning_at (loc, OPT_Wvector_operation_performance, + "vector operation will be expanded with a " + "single scalar operation"); scalar_int_mode mode = int_mode_for_size (tree_to_uhwi (TYPE_SIZE (type)), 0).require (); compute_type = lang_hooks.types.type_for_mode (mode, 1); result = f (gsi, compute_type, a, b, bitsize_zero_node, TYPE_SIZE (compute_type), code, type); - warning_at (loc, OPT_Wvector_operation_performance, - "vector operation will be expanded with a " - "single scalar operation"); } return result; @@ -487,8 +492,10 @@ expand_vector_comparison (gimple_stmt_iterator *gsi, tree type, tree op0, if (TYPE_PRECISION (ret_inner_type) != 1) ret_inner_type = build_nonstandard_integer_type (1, 1); - warning_at (loc, OPT_Wvector_operation_performance, - "vector operation will be expanded piecewise"); + if (!warning_suppressed_p (gsi_stmt (*gsi), + OPT_Wvector_operation_performance)) + warning_at (loc, OPT_Wvector_operation_performance, + "vector operation will be expanded piecewise"); for (i = 0; i < nunits; i++, index = int_const_binop (PLUS_EXPR, index, part_width)) { @@ -1098,8 +1105,9 @@ expand_vector_condition (gimple_stmt_iterator *gsi, bitmap dce_ssa_names) /* TODO: try and find a smaller vector type. */ - warning_at (loc, OPT_Wvector_operation_performance, - "vector condition will be expanded piecewise"); + if (!warning_suppressed_p (stmt, OPT_Wvector_operation_performance)) + warning_at (loc, OPT_Wvector_operation_performance, + "vector condition will be expanded piecewise"); if (!a_is_comparison && VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (a)) @@ -1591,9 +1599,10 @@ lower_vec_perm (gimple_stmt_iterator *gsi) } else if (can_vec_perm_var_p (TYPE_MODE (vect_type))) return; - - warning_at (loc, OPT_Wvector_operation_performance, - "vector shuffling operation will be expanded piecewise"); + + if (!warning_suppressed_p (stmt, OPT_Wvector_operation_performance)) + warning_at (loc, OPT_Wvector_operation_performance, + "vector shuffling operation will be expanded piecewise"); vec_alloc (v, elements); bool constant_p = true; @@ -2029,8 +2038,12 @@ expand_vector_conversion (gimple_stmt_iterator *gsi) location_t loc = gimple_location (gsi_stmt (*gsi)); if (compute_type != arg_type) - warning_at (loc, OPT_Wvector_operation_performance, - "vector operation will be expanded piecewise"); + { + if (!warning_suppressed_p (gsi_stmt (*gsi), + OPT_Wvector_operation_performance)) + warning_at (loc, OPT_Wvector_operation_performance, + "vector operation will be expanded piecewise"); + } else { nunits = 1; diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 29d6b2a2ae7..3f8d5aac8ee 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -6456,6 +6456,8 @@ vectorizable_operation (vec_info *vinfo, new_temp = make_ssa_name (vec_dest, new_stmt); gimple_assign_set_lhs (new_stmt, new_temp); vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); + if (using_emulated_vectors_p) + suppress_warning (new_stmt, OPT_Wvector_operation_performance); /* Enter the combined value into the vector cond hash so we don't AND it with a loop mask again. */