From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id A07273858D35 for ; Wed, 28 Jun 2023 09:12:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A07273858D35 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-out2.suse.de (Postfix) with ESMTP id 8D17E1F8C4 for ; Wed, 28 Jun 2023 09:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1687943553; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=8vUf38sT+XnlK1uReHEZpMJAVntOfk/sEnpXBnmKYVI=; b=kWS80MyozIeQO55G9IJEfW3xIct5GCxrH4z9G1ORxcsS4mXzHr9BUtTmXH+yAZPOpPEjG1 +vPhxJ2XIpz+7ytCR6OO4BKr2Hy0/knyBNye6uDauNWc2rnlLx7rHdXr0YF5E7edO6dCCY AWn4JKYOHuo8k7ZdRNZ9Ohzzh8mCH5c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1687943553; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=8vUf38sT+XnlK1uReHEZpMJAVntOfk/sEnpXBnmKYVI=; b=Ious+FQW08ZOHUxbyKjqDiE+EzonGdp8jaxck9jQ/giGNc+Amk9rmNFq5Kuq7pqt5bn+Se is9Q/q1+KRZwD9AA== 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 81CC22C2D4 for ; Wed, 28 Jun 2023 09:12:33 +0000 (UTC) Date: Wed, 28 Jun 2023 09:12:33 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/110443 - prevent SLP splat of gathers 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.5 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 List-Id: Message-ID: <20230628091233.4kFm1bAQXDLtxQTkFyJSoULqzTQtMYxA7MRsehnEGtM@z> The following prevents non-grouped load SLP in case the element to splat is from a gather operation. While it should be possible to support this it is not similar to the single element interleaving case I was trying to mimic here. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/110443 * tree-vect-slp.cc (vect_build_slp_tree_1): Reject non-grouped gather loads. * gcc.dg/torture/pr110443.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr110443.c | 21 +++++++++++++++++++++ gcc/tree-vect-slp.cc | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr110443.c diff --git a/gcc/testsuite/gcc.dg/torture/pr110443.c b/gcc/testsuite/gcc.dg/torture/pr110443.c new file mode 100644 index 00000000000..61cf705869c --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr110443.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +typedef struct { + float real; + float imag; +} complex_t; +extern unsigned char fftorder[]; +float *a52_imdct_256_data; +int a52_imdct_256_i, a52_imdct_256_k; +float a52_imdct_256_b_r; +void a52_imdct_256() +{ + complex_t buf1[64]; + a52_imdct_256_i = 0; + for (; a52_imdct_256_i < 64; a52_imdct_256_i++) { + a52_imdct_256_k = fftorder[a52_imdct_256_i]; + buf1[a52_imdct_256_i].real = buf1[a52_imdct_256_i].imag = + a52_imdct_256_data[a52_imdct_256_k]; + } + a52_imdct_256_b_r = buf1[0].real * buf1[0].imag; +} diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 8cb1ac1f319..355d078d66e 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -1291,7 +1291,8 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char *swap, vectorization. For loop vectorization we can handle splats the same we handle single element interleaving. */ && (is_a (vinfo) - || stmt_info != first_stmt_info)) + || stmt_info != first_stmt_info + || STMT_VINFO_GATHER_SCATTER_P (stmt_info))) { /* Not grouped load. */ if (dump_enabled_p ()) -- 2.35.3