From patchwork Wed Aug 28 10:42:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1977783 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=OvQqLkQs; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=SPd3By15; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=OvQqLkQs; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=SPd3By15; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wv1GL6lLtz1yZd for ; Wed, 28 Aug 2024 20:43:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B9FA3861015 for ; Wed, 28 Aug 2024 10:43:03 +0000 (GMT) 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.223.130]) by sourceware.org (Postfix) with ESMTPS id 5F80F3865467 for ; Wed, 28 Aug 2024 10:42:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F80F3865467 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5F80F3865467 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724841761; cv=none; b=MQXtURqjiUHQqiDpC6G0LgYP+3o8x9N66UFOaDWjDEdZJxDeR3ULs1RZHlMz2FqlLGLfPKjn2oEzkScd3kmYEuhkjn2NduR67hbL95quwXxH3Iac/RxFlHG5t/nVs98C5AF7EkHqqO4wYt3LS/ZgTuFdKSfL/S4xkhk95bZkEyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724841761; c=relaxed/simple; bh=70pQeTkJ/BPCc1i3QmDThHfls+WA5Fwy3dGBDBBKB3E=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=T8njB6prnfpMcPxObr4bo2QXTKsRnEIqQY1FsLpDaMwWCkHgy2/JR1JIrCxvH4nVn0uAux4R5jrbp1dPx8uR/DpHGJcFPDaZ3hdQvR0dtXgtYEqZ7EfL3+GcHnp72NTSCZc8z4PTJByvhHwqa5jFY5rJHDx8WonMvlcvV+TD9e0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from murzim.nue2.suse.org (unknown [10.168.4.243]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 620F8219DF for ; Wed, 28 Aug 2024 10:42:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724841755; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=seFSqMy0Bekb9KLzs413MCcEfU4xgZq6+sqsY023XyA=; b=OvQqLkQsLG1uj3X28ilRN6+fo/uX9rwgfbs8WUZ+Sagt61M/7nxeB2MTbYKbh95uhtXtOI ZKa9Ld2YWc1w6vgmNbpsgW3Ba9KhvXhOmgd5a/SjgR1p3KEVbONaf9qmy6gJMxx/UiOqwJ XX78aNCYdlPeHUuturY2FxrHn+EsJq0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724841755; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=seFSqMy0Bekb9KLzs413MCcEfU4xgZq6+sqsY023XyA=; b=SPd3By15jy6TkFnFFhlFUOlxrTaXa5jm7bsIxXK1wyrZepKBE7rvavtwFyDd3hy/0GfCje +ILLyz7aq8i1YZCw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1724841755; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=seFSqMy0Bekb9KLzs413MCcEfU4xgZq6+sqsY023XyA=; b=OvQqLkQsLG1uj3X28ilRN6+fo/uX9rwgfbs8WUZ+Sagt61M/7nxeB2MTbYKbh95uhtXtOI ZKa9Ld2YWc1w6vgmNbpsgW3Ba9KhvXhOmgd5a/SjgR1p3KEVbONaf9qmy6gJMxx/UiOqwJ XX78aNCYdlPeHUuturY2FxrHn+EsJq0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1724841755; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=seFSqMy0Bekb9KLzs413MCcEfU4xgZq6+sqsY023XyA=; b=SPd3By15jy6TkFnFFhlFUOlxrTaXa5jm7bsIxXK1wyrZepKBE7rvavtwFyDd3hy/0GfCje +ILLyz7aq8i1YZCw== Date: Wed, 28 Aug 2024 12:42:35 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Split out vect_build_slp_store_interleaving MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-1.13 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.38)[-0.383]; NEURAL_HAM_SHORT(-0.15)[-0.739]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; MISSING_XM_UA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_NONE(0.00)[]; MIME_TRACE(0.00)[0:+] X-Spam-Score: -1.13 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Message-Id: <20240828104303.3B9FA3861015@sourceware.org> This splits out SLP store interleaving into a separate function. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * tree-vect-slp.cc (vect_build_slp_store_interleaving): Split out from ... (vect_build_slp_instance): Here. --- gcc/tree-vect-slp.cc | 356 ++++++++++++++++++++++--------------------- 1 file changed, 182 insertions(+), 174 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index d6f34d0b73d..79d83efb015 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -3457,6 +3457,186 @@ vect_analyze_slp_instance (vec_info *vinfo, stmt_vec_info stmt_info, slp_instance_kind kind, unsigned max_tree_size, unsigned *limit); +/* Build an interleaving scheme for the store sources RHS_NODES from + SCALAR_STMTS. */ + +static slp_tree +vect_build_slp_store_interleaving (vec &rhs_nodes, + vec &scalar_stmts) +{ + unsigned int group_size = scalar_stmts.length (); + slp_tree node = vect_create_new_slp_node (scalar_stmts, + SLP_TREE_CHILDREN + (rhs_nodes[0]).length ()); + SLP_TREE_VECTYPE (node) = SLP_TREE_VECTYPE (rhs_nodes[0]); + for (unsigned l = 0; + l < SLP_TREE_CHILDREN (rhs_nodes[0]).length (); ++l) + { + /* And a permute merging all RHS SLP trees. */ + slp_tree perm = vect_create_new_slp_node (rhs_nodes.length (), + VEC_PERM_EXPR); + SLP_TREE_CHILDREN (node).quick_push (perm); + SLP_TREE_LANE_PERMUTATION (perm).create (group_size); + SLP_TREE_VECTYPE (perm) = SLP_TREE_VECTYPE (node); + SLP_TREE_LANES (perm) = group_size; + /* ??? We should set this NULL but that's not expected. */ + SLP_TREE_REPRESENTATIVE (perm) + = SLP_TREE_REPRESENTATIVE (SLP_TREE_CHILDREN (rhs_nodes[0])[l]); + for (unsigned j = 0; j < rhs_nodes.length (); ++j) + { + SLP_TREE_CHILDREN (perm) + .quick_push (SLP_TREE_CHILDREN (rhs_nodes[j])[l]); + for (unsigned k = 0; + k < SLP_TREE_SCALAR_STMTS (rhs_nodes[j]).length (); ++k) + { + /* ??? We should populate SLP_TREE_SCALAR_STMTS + or SLP_TREE_SCALAR_OPS but then we might have + a mix of both in our children. */ + SLP_TREE_LANE_PERMUTATION (perm) + .quick_push (std::make_pair (j, k)); + } + } + + /* Now we have a single permute node but we cannot code-generate + the case with more than two inputs. + Perform pairwise reduction, reducing the two inputs + with the least number of lanes to one and then repeat until + we end up with two inputs. That scheme makes sure we end + up with permutes satisfying the restriction of requiring at + most two vector inputs to produce a single vector output + when the number of lanes is even. */ + while (SLP_TREE_CHILDREN (perm).length () > 2) + { + /* When we have three equal sized groups left the pairwise + reduction does not result in a scheme that avoids using + three vectors. Instead merge the first two groups + to the final size with do-not-care elements (chosen + from the first group) and then merge with the third. + { A0, B0, x, A1, B1, x, ... } + -> { A0, B0, C0, A1, B1, C1, ... } + This handles group size of three (and at least + power-of-two multiples of that). */ + if (SLP_TREE_CHILDREN (perm).length () == 3 + && (SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[0]) + == SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[1])) + && (SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[0]) + == SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[2]))) + { + int ai = 0; + int bi = 1; + slp_tree a = SLP_TREE_CHILDREN (perm)[ai]; + slp_tree b = SLP_TREE_CHILDREN (perm)[bi]; + unsigned n = SLP_TREE_LANES (perm); + + slp_tree permab = vect_create_new_slp_node (2, VEC_PERM_EXPR); + SLP_TREE_LANES (permab) = n; + SLP_TREE_LANE_PERMUTATION (permab).create (n); + SLP_TREE_VECTYPE (permab) = SLP_TREE_VECTYPE (perm); + /* ??? Should be NULL but that's not expected. */ + SLP_TREE_REPRESENTATIVE (permab) = SLP_TREE_REPRESENTATIVE (perm); + SLP_TREE_CHILDREN (permab).quick_push (a); + for (unsigned k = 0; k < SLP_TREE_LANES (a); ++k) + SLP_TREE_LANE_PERMUTATION (permab) + .quick_push (std::make_pair (0, k)); + SLP_TREE_CHILDREN (permab).quick_push (b); + for (unsigned k = 0; k < SLP_TREE_LANES (b); ++k) + SLP_TREE_LANE_PERMUTATION (permab) + .quick_push (std::make_pair (1, k)); + /* Push the do-not-care lanes. */ + for (unsigned k = 0; k < SLP_TREE_LANES (a); ++k) + SLP_TREE_LANE_PERMUTATION (permab) + .quick_push (std::make_pair (0, k)); + + /* Put the merged node into 'perm', in place of a. */ + SLP_TREE_CHILDREN (perm)[ai] = permab; + /* Adjust the references to b in the permutation + of perm and to the later children which we'll + remove. */ + for (unsigned k = 0; k < SLP_TREE_LANES (perm); ++k) + { + std::pair &p + = SLP_TREE_LANE_PERMUTATION (perm)[k]; + if (p.first == (unsigned) bi) + { + p.first = ai; + p.second += SLP_TREE_LANES (a); + } + else if (p.first > (unsigned) bi) + p.first--; + } + SLP_TREE_CHILDREN (perm).ordered_remove (bi); + break; + } + + /* Pick the two nodes with the least number of lanes, + prefer the earliest candidate and maintain ai < bi. */ + int ai = -1; + int bi = -1; + for (unsigned ci = 0; ci < SLP_TREE_CHILDREN (perm).length (); ++ci) + { + if (ai == -1) + ai = ci; + else if (bi == -1) + bi = ci; + else if ((SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[ci]) + < SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[ai])) + || (SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[ci]) + < SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[bi]))) + { + if (SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[ai]) + <= SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[bi])) + bi = ci; + else + { + ai = bi; + bi = ci; + } + } + } + + /* Produce a merge of nodes ai and bi. */ + slp_tree a = SLP_TREE_CHILDREN (perm)[ai]; + slp_tree b = SLP_TREE_CHILDREN (perm)[bi]; + unsigned n = SLP_TREE_LANES (a) + SLP_TREE_LANES (b); + slp_tree permab = vect_create_new_slp_node (2, VEC_PERM_EXPR); + SLP_TREE_LANES (permab) = n; + SLP_TREE_LANE_PERMUTATION (permab).create (n); + SLP_TREE_VECTYPE (permab) = SLP_TREE_VECTYPE (perm); + /* ??? Should be NULL but that's not expected. */ + SLP_TREE_REPRESENTATIVE (permab) = SLP_TREE_REPRESENTATIVE (perm); + SLP_TREE_CHILDREN (permab).quick_push (a); + for (unsigned k = 0; k < SLP_TREE_LANES (a); ++k) + SLP_TREE_LANE_PERMUTATION (permab) + .quick_push (std::make_pair (0, k)); + SLP_TREE_CHILDREN (permab).quick_push (b); + for (unsigned k = 0; k < SLP_TREE_LANES (b); ++k) + SLP_TREE_LANE_PERMUTATION (permab) + .quick_push (std::make_pair (1, k)); + + /* Put the merged node into 'perm', in place of a. */ + SLP_TREE_CHILDREN (perm)[ai] = permab; + /* Adjust the references to b in the permutation + of perm and to the later children which we'll + remove. */ + for (unsigned k = 0; k < SLP_TREE_LANES (perm); ++k) + { + std::pair &p + = SLP_TREE_LANE_PERMUTATION (perm)[k]; + if (p.first == (unsigned) bi) + { + p.first = ai; + p.second += SLP_TREE_LANES (a); + } + else if (p.first > (unsigned) bi) + p.first--; + } + SLP_TREE_CHILDREN (perm).ordered_remove (bi); + } + } + + return node; +} + /* Analyze an SLP instance starting from SCALAR_STMTS which are a group of KIND. Return true if successful. */ @@ -3766,180 +3946,8 @@ vect_build_slp_instance (vec_info *vinfo, } } - /* Now we assume we can build the root SLP node from all - stores. */ - node = vect_create_new_slp_node (scalar_stmts, - SLP_TREE_CHILDREN - (rhs_nodes[0]).length ()); - SLP_TREE_VECTYPE (node) = SLP_TREE_VECTYPE (rhs_nodes[0]); - for (unsigned l = 0; - l < SLP_TREE_CHILDREN (rhs_nodes[0]).length (); ++l) - { - /* And a permute merging all RHS SLP trees. */ - slp_tree perm = vect_create_new_slp_node (rhs_nodes.length (), - VEC_PERM_EXPR); - SLP_TREE_CHILDREN (node).quick_push (perm); - SLP_TREE_LANE_PERMUTATION (perm).create (group_size); - SLP_TREE_VECTYPE (perm) = SLP_TREE_VECTYPE (node); - SLP_TREE_LANES (perm) = group_size; - /* ??? We should set this NULL but that's not expected. */ - SLP_TREE_REPRESENTATIVE (perm) - = SLP_TREE_REPRESENTATIVE (SLP_TREE_CHILDREN (rhs_nodes[0])[l]); - for (unsigned j = 0; j < rhs_nodes.length (); ++j) - { - SLP_TREE_CHILDREN (perm) - .quick_push (SLP_TREE_CHILDREN (rhs_nodes[j])[l]); - for (unsigned k = 0; - k < SLP_TREE_SCALAR_STMTS (rhs_nodes[j]).length (); ++k) - { - /* ??? We should populate SLP_TREE_SCALAR_STMTS - or SLP_TREE_SCALAR_OPS but then we might have - a mix of both in our children. */ - SLP_TREE_LANE_PERMUTATION (perm) - .quick_push (std::make_pair (j, k)); - } - } - - /* Now we have a single permute node but we cannot code-generate - the case with more than two inputs. - Perform pairwise reduction, reducing the two inputs - with the least number of lanes to one and then repeat until - we end up with two inputs. That scheme makes sure we end - up with permutes satisfying the restriction of requiring at - most two vector inputs to produce a single vector output. */ - while (SLP_TREE_CHILDREN (perm).length () > 2) - { - /* When we have three equal sized groups left the pairwise - reduction does not result in a scheme that avoids using - three vectors. Instead merge the first two groups - to the final size with do-not-care elements (chosen - from the first group) and then merge with the third. - { A0, B0, x, A1, B1, x, ... } - -> { A0, B0, C0, A1, B1, C1, ... } - This handles group size of three (and at least - power-of-two multiples of that). */ - if (SLP_TREE_CHILDREN (perm).length () == 3 - && (SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[0]) - == SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[1])) - && (SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[0]) - == SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[2]))) - { - int ai = 0; - int bi = 1; - slp_tree a = SLP_TREE_CHILDREN (perm)[ai]; - slp_tree b = SLP_TREE_CHILDREN (perm)[bi]; - unsigned n = SLP_TREE_LANES (perm); - - slp_tree permab - = vect_create_new_slp_node (2, VEC_PERM_EXPR); - SLP_TREE_LANES (permab) = n; - SLP_TREE_LANE_PERMUTATION (permab).create (n); - SLP_TREE_VECTYPE (permab) = SLP_TREE_VECTYPE (perm); - /* ??? Should be NULL but that's not expected. */ - SLP_TREE_REPRESENTATIVE (permab) - = SLP_TREE_REPRESENTATIVE (perm); - SLP_TREE_CHILDREN (permab).quick_push (a); - for (unsigned k = 0; k < SLP_TREE_LANES (a); ++k) - SLP_TREE_LANE_PERMUTATION (permab) - .quick_push (std::make_pair (0, k)); - SLP_TREE_CHILDREN (permab).quick_push (b); - for (unsigned k = 0; k < SLP_TREE_LANES (b); ++k) - SLP_TREE_LANE_PERMUTATION (permab) - .quick_push (std::make_pair (1, k)); - /* Push the do-not-care lanes. */ - for (unsigned k = 0; k < SLP_TREE_LANES (a); ++k) - SLP_TREE_LANE_PERMUTATION (permab) - .quick_push (std::make_pair (0, k)); - - /* Put the merged node into 'perm', in place of a. */ - SLP_TREE_CHILDREN (perm)[ai] = permab; - /* Adjust the references to b in the permutation - of perm and to the later children which we'll - remove. */ - for (unsigned k = 0; k < SLP_TREE_LANES (perm); ++k) - { - std::pair &p - = SLP_TREE_LANE_PERMUTATION (perm)[k]; - if (p.first == (unsigned) bi) - { - p.first = ai; - p.second += SLP_TREE_LANES (a); - } - else if (p.first > (unsigned) bi) - p.first--; - } - SLP_TREE_CHILDREN (perm).ordered_remove (bi); - break; - } - - /* Pick the two nodes with the least number of lanes, - prefer the earliest candidate and maintain ai < bi. */ - int ai = -1; - int bi = -1; - for (unsigned ci = 0; - ci < SLP_TREE_CHILDREN (perm).length (); ++ci) - { - if (ai == -1) - ai = ci; - else if (bi == -1) - bi = ci; - else if ((SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[ci]) - < SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[ai])) - || (SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[ci]) - < SLP_TREE_LANES - (SLP_TREE_CHILDREN (perm)[bi]))) - { - if (SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[ai]) - <= SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[bi])) - bi = ci; - else - { - ai = bi; - bi = ci; - } - } - } - - /* Produce a merge of nodes ai and bi. */ - slp_tree a = SLP_TREE_CHILDREN (perm)[ai]; - slp_tree b = SLP_TREE_CHILDREN (perm)[bi]; - unsigned n = SLP_TREE_LANES (a) + SLP_TREE_LANES (b); - slp_tree permab = vect_create_new_slp_node (2, VEC_PERM_EXPR); - SLP_TREE_LANES (permab) = n; - SLP_TREE_LANE_PERMUTATION (permab).create (n); - SLP_TREE_VECTYPE (permab) = SLP_TREE_VECTYPE (perm); - /* ??? Should be NULL but that's not expected. */ - SLP_TREE_REPRESENTATIVE (permab) - = SLP_TREE_REPRESENTATIVE (perm); - SLP_TREE_CHILDREN (permab).quick_push (a); - for (unsigned k = 0; k < SLP_TREE_LANES (a); ++k) - SLP_TREE_LANE_PERMUTATION (permab) - .quick_push (std::make_pair (0, k)); - SLP_TREE_CHILDREN (permab).quick_push (b); - for (unsigned k = 0; k < SLP_TREE_LANES (b); ++k) - SLP_TREE_LANE_PERMUTATION (permab) - .quick_push (std::make_pair (1, k)); - - /* Put the merged node into 'perm', in place of a. */ - SLP_TREE_CHILDREN (perm)[ai] = permab; - /* Adjust the references to b in the permutation - of perm and to the later children which we'll - remove. */ - for (unsigned k = 0; k < SLP_TREE_LANES (perm); ++k) - { - std::pair &p - = SLP_TREE_LANE_PERMUTATION (perm)[k]; - if (p.first == (unsigned) bi) - { - p.first = ai; - p.second += SLP_TREE_LANES (a); - } - else if (p.first > (unsigned) bi) - p.first--; - } - SLP_TREE_CHILDREN (perm).ordered_remove (bi); - } - } + /* Now we assume we can build the root SLP node from all stores. */ + node = vect_build_slp_store_interleaving (rhs_nodes, scalar_stmts); /* Create a new SLP instance. */ slp_instance new_instance = XNEW (class _slp_instance);