From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id B4665385843E; Fri, 23 Jun 2023 08:12:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4665385843E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687507929; bh=yUQE8TBGrfGTKn5xGuIdjSHBdTAJ8siq9uhCU91e2LQ=; h=From:To:Subject:Date:From; b=BdbSZ1Fb5TsmZQ6dNsfib+gVlhFw6s28zOBcld0LGCjwGca3TdXu+a4TWAYu8/dBH Vujeq1OIIarBUc/BR1fnZwZBamfETcEHiid5NVZUnnoDsP8O/o6587Yz9qESbiA1iK 4v1CbwsBfYll/9e7g2uzXbd7OxovgfPMWpm66ti0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-2039] Optimize vector codegen for invariant loads, fix SLP support X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 1742ea94aaa758a2b0c40360f89e27770bd8ffeb X-Git-Newrev: efc7fadff587b675552cd130cffe8c96c0feb4fc Message-Id: <20230623081209.B4665385843E@sourceware.org> Date: Fri, 23 Jun 2023 08:12:09 +0000 (GMT) List-Id: https://gcc.gnu.org/g:efc7fadff587b675552cd130cffe8c96c0feb4fc commit r14-2039-gefc7fadff587b675552cd130cffe8c96c0feb4fc Author: Richard Biener Date: Fri Jun 23 09:28:34 2023 +0200 Optimize vector codegen for invariant loads, fix SLP support The following avoids creating duplicate stmts for invariant loads which was necessary when the vector stmts were in a linked list. It also fixes SLP support which didn't correctly create the appropriate number of copies. * tree-vect-stmts.cc (vectorizable_load): Avoid useless copies of VMAT_INVARIANT vectorized stmts, fix SLP support. Diff: --- gcc/tree-vect-stmts.cc | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 9e046ced7c6..e6649789540 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -9593,27 +9593,26 @@ vectorizable_load (vec_info *vinfo, gimple_set_vuse (new_stmt, vuse); gsi_insert_on_edge_immediate (pe, new_stmt); } - /* These copies are all equivalent, but currently the representation - requires a separate STMT_VINFO_VEC_STMT for each one. */ - gimple_stmt_iterator gsi2 = *gsi; - gsi_next (&gsi2); - for (j = 0; j < ncopies; j++) + /* These copies are all equivalent. */ + if (hoist_p) + new_temp = vect_init_vector (vinfo, stmt_info, scalar_dest, + vectype, NULL); + else { - if (hoist_p) - new_temp = vect_init_vector (vinfo, stmt_info, scalar_dest, - vectype, NULL); - else - new_temp = vect_init_vector (vinfo, stmt_info, scalar_dest, - vectype, &gsi2); - gimple *new_stmt = SSA_NAME_DEF_STMT (new_temp); - if (slp) - SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt); - else - { - if (j == 0) - *vec_stmt = new_stmt; - STMT_VINFO_VEC_STMTS (stmt_info).safe_push (new_stmt); - } + gimple_stmt_iterator gsi2 = *gsi; + gsi_next (&gsi2); + new_temp = vect_init_vector (vinfo, stmt_info, scalar_dest, + vectype, &gsi2); + } + gimple *new_stmt = SSA_NAME_DEF_STMT (new_temp); + if (slp) + for (j = 0; j < (int) SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node); ++j) + SLP_TREE_VEC_STMTS (slp_node).quick_push (new_stmt); + else + { + for (j = 0; j < ncopies; ++j) + STMT_VINFO_VEC_STMTS (stmt_info).safe_push (new_stmt); + *vec_stmt = new_stmt; } return true; }