From patchwork Tue Nov 21 07:20:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 167519 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp449461vqb; Mon, 20 Nov 2023 23:20:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdowa/hTi5jN9buVOx6sdAPe3KAQDSZIF3zAdi/jl70wBm/FTNRMRYr9cuB2YmhqlQqtrR X-Received: by 2002:a05:6214:4008:b0:679:e379:1f3f with SMTP id kd8-20020a056214400800b00679e3791f3fmr3807828qvb.8.1700551242943; Mon, 20 Nov 2023 23:20:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700551242; cv=pass; d=google.com; s=arc-20160816; b=z7aai++wLiwemRUXiJz734zGdbV6ptH3KZ5g92RrK2P2ZgGagIPxtnEFM1SMUt70Ol U1TsOA+GHZQ6jY4OhsYcK141SkTFyVEho5yIMY+ydeHaoI4ydBfrlohpXbI30QH7xsR4 DNXPb+WX4QVlME8aKQuV9yGCQryCgAdU/Ay4l81Nz18MZphRfR7uvQo7iZ8hRh/UAyeM PWA2DtlcBTQCn93BP8/+kK+hIPbIlcTfBsB1RlCIvBgnkYreHNSGTN/SmKl7xMcXP4mB Bwvk8RSB2v4Uy35Y3vMxdh7XqLeileTvIgFBiG8v9oY0nxYWh1SX2wQ+Cyq4PcVWChji q7Tg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:errors-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:subject:to:from:date:dkim-signature:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=z/y6Y7bP7AdOboaAkUQ+zeHTmGTqcHEz0al+uoCLuA0=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=NlAv14UZO0wqMQqyPP2axR6eJsRPh+FZGY+NJADIRZZ7T1J3DYa9+sSNv9UU5GzMJC 2YKGXN8eOomH2SzIuC3qOGe9h6y63cFfWCm8LDU/DgYvcL5tynYQQnVmhwAiHdiFeOcj 0295qNFhA4c7kXc/aElhh5cGD6hPrMEohTJsIwK0AMrPAi1Fu9GCj6vgo9iP2WPBdx4G m9gGPjsMWCbpV6XE2yMIjKnL/7BcmGYkA1DqGr+JUYrwhifT36jCIdDH8Ul3lPQttx9L upY0dRASli3dc8lwlJCLYW4aLEVhTax3o3ELkBAYHVIAwA2hTboHHCtcsR9T3mERz2Lm kYZQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ywJXI9TH; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=2UNpp34I; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l8-20020a0ce6c8000000b0066ad6036429si8682694qvn.554.2023.11.20.23.20.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 23:20:42 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=ywJXI9TH; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=2UNpp34I; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A6D4E3858C2F for ; Tue, 21 Nov 2023 07:20:42 +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 [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 0658B3858D35 for ; Tue, 21 Nov 2023 07:20:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0658B3858D35 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 0658B3858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:67c:2178:6::1c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700551219; cv=none; b=vOrIgatpjwc2iQ3D2qT8vTL+hip8juYK315/jrjCbI84M85sPJdEcBSKvhaLWpLuufZEKsQgYuw/CE/jJBB6Ibx8hDF00v6c5vQTpij1roO0Dqk9p+jrWRRihu9z/Ie6Awvb2jERDrqek1+O2xhaWUaVF551a3kZE4Pq4nF7k6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700551219; c=relaxed/simple; bh=wRbBe5ZR7SIVsE/dOhgRYucmL+Op5ows7Z8svDjygjo=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:MIME-Version; b=Fl12xo8jsxT6WPnk9QSz73FqK4z183CoXiUWVAUEqZbt8i/YWo+LPQ2iqs3NagdWVuhcD+5dQoIGDW7+aODztGyxhLmIbwlBlp6yB/G9ofCRtKvKxFj5uKPSIdHY/1PZQw4f/sdBFnwJTOOCpThiTVUOCiRzUxPbmHry6XtZbKs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id F1D3121941 for ; Tue, 21 Nov 2023 07:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1700551216; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=z/y6Y7bP7AdOboaAkUQ+zeHTmGTqcHEz0al+uoCLuA0=; b=ywJXI9THm/qKImzlEBhbGcxI1vqDG6QowvEfG3AF4x50APIu3BkYKRNpwGicXvK24EvUkS M4g52RcuHn16+Bc2ed1mcZtUhgcxcFN4A9Y9wo/wg3sy3YJs5FlxJEzcbE7Lp2D+c9yyGU B+kByskai7TZRZViWKr9Zfki5vxSGGI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1700551216; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=z/y6Y7bP7AdOboaAkUQ+zeHTmGTqcHEz0al+uoCLuA0=; b=2UNpp34IUQ8gkRIvkpUVP4NSDzfp5Hw2Jmb53/shEDV4/whCnJzrrOMjs6cxRmCurm5wBP T0JNujIEeWp1w0CQ== 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 E53762C14B for ; Tue, 21 Nov 2023 07:20:16 +0000 (UTC) Date: Tue, 21 Nov 2023 07:20:16 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/111970 - fix issue with SLP of emulated gather/scatter User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spamd-Bar: ++++++++++++++++ Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=none; spf=softfail (smtp-out1.suse.de: 149.44.160.134 is neither permitted nor denied by domain of rguenther@suse.de) smtp.mailfrom=rguenther@suse.de X-Rspamd-Server: rspamd1 X-Spamd-Result: default: False [16.49 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RWL_MAILSPIKE_GOOD(-1.00)[149.44.160.134:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(3.00)[1.000]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; TO_DN_NONE(0.00)[]; R_SPF_SOFTFAIL(4.60)[~all:c]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MX_GOOD(-0.01)[]; NEURAL_SPAM_LONG(3.50)[1.000]; DMARC_NA(1.20)[suse.de]; VIOLATED_DIRECT_SPF(3.50)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-3.00)[99.99%] X-Spam-Score: 16.49 X-Rspamd-Queue-Id: F1D3121941 X-Spam-Status: No, score=-10.7 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+ouuuleilei=gmail.com@gcc.gnu.org Message-Id: <20231121072042.A6D4E3858C2F@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783157220168850963 X-GMAIL-MSGID: 1783157220168850963 There's a missed index adjustment for the SLP vector number when computing the index/data vectors for emulated gather/scatter with SLP. The following fixes this. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/111970 * tree-vect-stmts.cc (vectorizable_load): Fix offset calculation for SLP gather load. (vectorizable_store): Likewise for SLP scatter store. --- gcc/tree-vect-stmts.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 96e4a6cffad..bf8c99779ae 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -9188,7 +9188,8 @@ vectorizable_store (vec_info *vinfo, unsigned HOST_WIDE_INT factor = const_offset_nunits / const_nunits; vec_offset = vec_offsets[(vec_num * j + i) / factor]; - unsigned elt_offset = (j % factor) * const_nunits; + unsigned elt_offset + = ((vec_num * j + i) % factor) * const_nunits; tree idx_type = TREE_TYPE (TREE_TYPE (vec_offset)); tree scale = size_int (gs_info.scale); align = get_object_alignment (DR_REF (first_dr_info->dr)); @@ -11150,7 +11151,8 @@ vectorizable_load (vec_info *vinfo, unsigned HOST_WIDE_INT factor = const_offset_nunits / const_nunits; vec_offset = vec_offsets[(vec_num * j + i) / factor]; - unsigned elt_offset = (j % factor) * const_nunits; + unsigned elt_offset + = ((vec_num * j + i) % factor) * const_nunits; tree idx_type = TREE_TYPE (TREE_TYPE (vec_offset)); tree scale = size_int (gs_info.scale); align = get_object_alignment (DR_REF (first_dr_info->dr));