From patchwork Fri Jun 14 07:03:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1947652 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=Ty5Pk05h; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+aQmB4pm; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=Ty5Pk05h; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+aQmB4pm; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4W0qy76zVJz20QH for ; Fri, 14 Jun 2024 17:03:59 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 44D86388217C for ; Fri, 14 Jun 2024 07:03:58 +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 53CD43882100 for ; Fri, 14 Jun 2024 07:03:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53CD43882100 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 53CD43882100 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=1718348618; cv=none; b=G443QNksATP3qwl19ojc7rcKp95CY7IO+jnl8tD/aU6Fli1mcdu5yaKwiBzizJxfnNFCe1aEY8tAIksuT+l0dKsZ2enHPC01MC+A0KCi4+Mx3QEVjsFXA48G2wkvckJJ7K5awTReEUq5G9IKcA/ZesfQkhPLDfkOri8Xbb+UQ2g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718348618; c=relaxed/simple; bh=jaPK7/2MdWcrounWHC2YKCZHX72T1o0RykJDsvvzRN4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version:Message-Id; b=pLMAHOmxXzmp2QEuunRVjpaSzo18nNeObkpNpBik0J0rzvIm9Si04UUPMgGF0fJM7Y+HE1IgOm1w5gCOv90Fnw5k7HMJzRZhmDUv5u088fKgrf78FM+0QAdd+nzOJrGNtNEcFlaxBgQxHSkn1zhCU6b1vWhRFaOZKzdtfw9o8Vc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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 5342722276 for ; Fri, 14 Jun 2024 07:03:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718348615; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=59WpuWZ8YuRKDh0zIMLjHgAf7HlqkOfCV0H5PDO+MIU=; b=Ty5Pk05hgKizB68vFw9AnHvgAS8S704QWjWSgiopCZdEz3p5VPGaTXQ7EFmsPjcXFfpkca WKwI6thSMKN/HL3reVWLRB0JsgHM5Iq6gz8YPMssoQ2IVhhrf4JIB7D5k1E3UwG51vUF6U kWYBdD6clpayvo+cZDApJm5NDv5Jut4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718348615; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=59WpuWZ8YuRKDh0zIMLjHgAf7HlqkOfCV0H5PDO+MIU=; b=+aQmB4pm7wf9OCtyH4W4fpWg6NDwGG1m0gamOqEMZu4kEgiqmfJMl90Nz/p6lm/5FbX8EF Tl8v3saEA0KQW4Cw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718348615; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=59WpuWZ8YuRKDh0zIMLjHgAf7HlqkOfCV0H5PDO+MIU=; b=Ty5Pk05hgKizB68vFw9AnHvgAS8S704QWjWSgiopCZdEz3p5VPGaTXQ7EFmsPjcXFfpkca WKwI6thSMKN/HL3reVWLRB0JsgHM5Iq6gz8YPMssoQ2IVhhrf4JIB7D5k1E3UwG51vUF6U kWYBdD6clpayvo+cZDApJm5NDv5Jut4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718348615; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type; bh=59WpuWZ8YuRKDh0zIMLjHgAf7HlqkOfCV0H5PDO+MIU=; b=+aQmB4pm7wf9OCtyH4W4fpWg6NDwGG1m0gamOqEMZu4kEgiqmfJMl90Nz/p6lm/5FbX8EF Tl8v3saEA0KQW4Cw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2446D13AB5 for ; Fri, 14 Jun 2024 07:03:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id hxhKBUfra2ZKSwAAD6G6ig (envelope-from ) for ; Fri, 14 Jun 2024 07:03:35 +0000 Date: Fri, 14 Jun 2024 09:03:34 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix fallout of peeling for gap improvements MIME-Version: 1.0 Message-Id: <20240614070335.2446D13AB5@imap1.dmz-prg2.suse.org> X-Spam-Score: -4.30 X-Spam-Level: X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.990]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; PREVIOUSLY_DELIVERED(0.00)[gcc-patches@gcc.gnu.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] X-Spam-Status: No, score=-11.6 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, 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 The following hopefully addresses an observed bootstrap issue on aarch64 where maybe-uninit diagnostics occur. It also fixes bogus napkin math from myself when I was confusing rounded up size of a single access with rounded up size of the group accessed in a single scalar iteration. So the following puts in a correctness check, leaving a set of peeling for gaps as insufficient. This could be rectified by splitting the last load into multiple ones but I'm leaving this for a followup, better quickly fix the reported wrong-code. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * tree-vect-stmts.cc (get_group_load_store_type): Do not re-use poly-int remain but re-compute with non-poly values. Verify the shortened load is good enough to be covered with a single scalar gap iteration before accepting it. * gcc.dg/vect/pr115385.c: Enable AVX2 if available. --- gcc/testsuite/gcc.dg/vect/pr115385.c | 1 + gcc/tree-vect-stmts.cc | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/pr115385.c b/gcc/testsuite/gcc.dg/vect/pr115385.c index a18cd665d7d..baea0b2473f 100644 --- a/gcc/testsuite/gcc.dg/vect/pr115385.c +++ b/gcc/testsuite/gcc.dg/vect/pr115385.c @@ -1,4 +1,5 @@ /* { dg-require-effective-target mmap } */ +/* { dg-additional-options "-mavx2" { target avx2_runtime } } */ #include #include diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index e32d44050e5..ca6052662a3 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -2148,15 +2148,17 @@ get_group_load_store_type (vec_info *vinfo, stmt_vec_info stmt_info, { /* But peeling a single scalar iteration is enough if we can use the next power-of-two sized partial - access. */ + access and that is sufficiently small to be covered + by the single scalar iteration. */ unsigned HOST_WIDE_INT cnunits, cvf, cremain, cpart_size; if (!nunits.is_constant (&cnunits) || !LOOP_VINFO_VECT_FACTOR (loop_vinfo).is_constant (&cvf) - || ((cremain = remain.to_constant (), true) + || (((cremain = group_size * cvf - gap % cnunits), true) && ((cpart_size = (1 << ceil_log2 (cremain))) != cnunits) - && vector_vector_composition_type - (vectype, cnunits / cpart_size, - &half_vtype) == NULL_TREE)) + && (cremain + group_size < cpart_size + || vector_vector_composition_type + (vectype, cnunits / cpart_size, + &half_vtype) == NULL_TREE))) { if (dump_enabled_p ()) dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,