From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 09479385E44A for ; Wed, 14 Jul 2021 10:31:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 09479385E44A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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-out2.suse.de (Postfix) with ESMTPS id E0A932028A for ; Wed, 14 Jul 2021 10:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1626258692; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=D7o6RWA4OWrcZlhnYAWhvEvU5uWZTELemPSd8pvrAlo=; b=Kfk8sO9o66m6BA34Gu2dbqjTXw2RbN5GUsd3eaB/w2NCq5Rqcsuy2xkGzI2WjW7NIgDThq XPhW2+2qJfJOKg5kXbcAUktCjuYNGXEfCAovzcX1Epn0IF5gRi41tv1GqQ8o1YcFDDGp9r M2nvh+VtW9qJ4BxG0YNpam68kN/vQvA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1626258692; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=D7o6RWA4OWrcZlhnYAWhvEvU5uWZTELemPSd8pvrAlo=; b=ki7xypAmiKiGhl+4LVcGCEk3TE08cplToffIZ0CQDQm6trQhW7MZYWTMYCgSwRj2Ghz+zQ V90KfC3xMnDISqDA== 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 C459C13BFD for ; Wed, 14 Jul 2021 10:31:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id d9hALgS97mDzMgAAMHmgww (envelope-from ) for ; Wed, 14 Jul 2021 10:31:32 +0000 Date: Wed, 14 Jul 2021 12:31:32 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/101445 - fix negative stride SLP vect with gaps Message-ID: <38qp6731-8op2-5pq-4655-o6p93os8r32p@fhfr.qr> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-11.3 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 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-List-Received-Date: Wed, 14 Jul 2021 10:31:37 -0000 The following fixes the IV adjustment for the gap in a negative stride SLP vectorization. The adjustment was in the wrong direction, now fixes as in the patch. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-07-14 Richard Biener PR tree-optimization/101445 * tree-vect-stmts.c (vectorizable_load): Do the gap adjustment of the IV in the correct direction for negative stride accesses. * gcc.dg/vect/pr101445.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr101445.c | 28 ++++++++++++++++++++++++++++ gcc/tree-vect-stmts.c | 6 ++++++ 2 files changed, 34 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/vect/pr101445.c diff --git a/gcc/testsuite/gcc.dg/vect/pr101445.c b/gcc/testsuite/gcc.dg/vect/pr101445.c new file mode 100644 index 00000000000..f8a6e9ce6f7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr101445.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ + +#include "tree-vect.h" + +int a[35] = { 1, 1, 3 }; + +void __attribute__((noipa)) +foo () +{ + for (int b = 4; b >= 0; b--) + { + int tem = a[b * 5 + 3 + 1]; + a[b * 5 + 3] = tem; + a[b * 5 + 2] = tem; + a[b * 5 + 1] = tem; + a[b * 5 + 0] = tem; + } +} + +int main() +{ + check_vect (); + foo (); + for (int d = 0; d < 25; d++) + if (a[d] != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index e590f34d75d..3980f0918b2 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -9759,6 +9759,9 @@ vectorizable_load (vec_info *vinfo, poly_wide_int bump_val = (wi::to_wide (TYPE_SIZE_UNIT (elem_type)) * group_gap_adj); + if (tree_int_cst_sgn + (vect_dr_behavior (vinfo, dr_info)->step) == -1) + bump_val = -bump_val; tree bump = wide_int_to_tree (sizetype, bump_val); dataref_ptr = bump_vector_ptr (vinfo, dataref_ptr, ptr_incr, gsi, stmt_info, bump); @@ -9772,6 +9775,9 @@ vectorizable_load (vec_info *vinfo, poly_wide_int bump_val = (wi::to_wide (TYPE_SIZE_UNIT (elem_type)) * group_gap_adj); + if (tree_int_cst_sgn + (vect_dr_behavior (vinfo, dr_info)->step) == -1) + bump_val = -bump_val; tree bump = wide_int_to_tree (sizetype, bump_val); dataref_ptr = bump_vector_ptr (vinfo, dataref_ptr, ptr_incr, gsi, stmt_info, bump); -- 2.26.2