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 DB2CE3856961 for ; Thu, 24 Aug 2023 12:41:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DB2CE3856961 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 0341022BB2 for ; Thu, 24 Aug 2023 12:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692880906; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=gkynkec21D2bjcmSFCVOjzPf6AnW4bC7hA4JphKFVKw=; b=amTYKZok6/gs5T4XUqde9ZoKQxHpPLG5ovQbJ6+INqiTzYPoE/BhF0EaLztFKpiSsXon2I p+s+1fIfZAiG0DoyrmxpwRKE/ImmwskBWkSjE3kjumpDn6CXzzMl94mauyS4mtyIhFvcqk 5stw6vM1Qye5XTAlf6J0594LSxuPu5w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692880906; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=gkynkec21D2bjcmSFCVOjzPf6AnW4bC7hA4JphKFVKw=; b=f+bxmBuW2KyaA9HZJAgz1YHY+glpOx/DHj6NrSymKsfO0cKaF0E3iwLb43jCgZh3f9zMsr bowqaRqLVn0v+7AQ== 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 F2F552C143 for ; Thu, 24 Aug 2023 12:41:45 +0000 (UTC) Date: Thu, 24 Aug 2023 12:41:45 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix confusion about load_p in vect_build_slp_tree_1 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=-10.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_NUMSUBJECT,MISSING_MID,SPF_HELO_NONE,SPF_PASS,TXREP 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: Message-ID: <20230824124145.dNBudsdBVBUP0xPqLazmDykhiaV6BMy3LKSX8r3H7nw@z> load_p is set and used as to whether the stmt is a memory operation, not whether it is only a load. The following renames it to ldst_p to avoid this confusion. It also replaces checking for a VUSE with checking STMT_VINFO_DATA_REF since VUSE checking doesn't work for pattern matched stores where no virtual operands are present. Where we want to distinguish between loads and stores we then check DR_IS_READ/WRITE. I've made a classification mistake with .MASK_STORE support and this hits other complications when dealing with single-lane SLP. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * tree-vect-slp.cc (vect_build_slp_tree_1): Rename load_p to ldst_p, fix mistakes and rely on STMT_VINFO_DATA_REF. --- gcc/tree-vect-slp.cc | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 0b1c2233017..0cf6e02285e 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -984,7 +984,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, bool need_same_oprnds = false; tree vectype = NULL_TREE, first_op1 = NULL_TREE; stmt_vec_info first_load = NULL, prev_first_load = NULL; - bool first_stmt_load_p = false, load_p = false; + bool first_stmt_ldst_p = false, ldst_p = false; bool first_stmt_phi_p = false, phi_p = false; bool maybe_soft_fail = false; tree soft_fail_nunits_vectype = NULL_TREE; @@ -1074,9 +1074,12 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, if (cfn == CFN_MASK_LOAD || cfn == CFN_GATHER_LOAD || cfn == CFN_MASK_GATHER_LOAD) - load_p = true; + ldst_p = true; else if (cfn == CFN_MASK_STORE) - rhs_code = CFN_MASK_STORE; + { + ldst_p = true; + rhs_code = CFN_MASK_STORE; + } else if ((internal_fn_p (cfn) && !vectorizable_internal_fn_p (as_internal_fn (cfn))) || gimple_call_tail_p (call_stmt) @@ -1102,7 +1105,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, else { rhs_code = gimple_assign_rhs_code (stmt); - load_p = gimple_vuse (stmt); + ldst_p = STMT_VINFO_DATA_REF (stmt_info) != nullptr; } /* Check the operation. */ @@ -1110,7 +1113,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, { *node_vectype = vectype; first_stmt_code = rhs_code; - first_stmt_load_p = load_p; + first_stmt_ldst_p = ldst_p; first_stmt_phi_p = phi_p; /* Shift arguments should be equal in all the packed stmts for a @@ -1144,7 +1147,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, need_same_oprnds = true; first_op1 = gimple_assign_rhs2 (stmt); } - else if (!load_p + else if (!ldst_p && rhs_code == BIT_FIELD_REF) { tree vec = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0); @@ -1207,7 +1210,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, || rhs_code == INDIRECT_REF || rhs_code == COMPONENT_REF || rhs_code == MEM_REF))) - || first_stmt_load_p != load_p + || first_stmt_ldst_p != ldst_p || first_stmt_phi_p != phi_p) { if (dump_enabled_p ()) @@ -1222,7 +1225,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, continue; } - if (!load_p + if (!ldst_p && first_stmt_code == BIT_FIELD_REF && (TREE_OPERAND (gimple_assign_rhs1 (first_stmt_info->stmt), 0) != TREE_OPERAND (gimple_assign_rhs1 (stmt_info->stmt), 0))) @@ -1291,12 +1294,13 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, /* Grouped store or load. */ if (STMT_VINFO_GROUPED_ACCESS (stmt_info)) { - if (!load_p) + gcc_assert (ldst_p); + if (DR_IS_WRITE (STMT_VINFO_DATA_REF (stmt_info))) { /* Store. */ gcc_assert (rhs_code == CFN_MASK_STORE - || REFERENCE_CLASS_P (lhs)); - ; + || REFERENCE_CLASS_P (lhs) + || DECL_P (lhs)); } else { @@ -1321,10 +1325,11 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, else prev_first_load = first_load; } - } /* Grouped access. */ - else + } + /* Non-grouped store or load. */ + else if (ldst_p) { - if (load_p + if (DR_IS_READ (STMT_VINFO_DATA_REF (stmt_info)) && rhs_code != CFN_GATHER_LOAD && rhs_code != CFN_MASK_GATHER_LOAD /* Not grouped loads are handled as externals for BB @@ -1345,10 +1350,11 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, matches[0] = false; return false; } - - /* Not memory operation. */ - if (!load_p - && !phi_p + } + /* Not memory operation. */ + else + { + if (!phi_p && rhs_code.is_tree_code () && TREE_CODE_CLASS (tree_code (rhs_code)) != tcc_binary && TREE_CODE_CLASS (tree_code (rhs_code)) != tcc_unary -- 2.35.3