From patchwork Tue Apr 16 10:36:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1924078 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=NyE0dSlV; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=fdL4b8a9; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=NyE0dSlV; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=fdL4b8a9; 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 4VJgT66gJSz1yZC for ; Tue, 16 Apr 2024 20:36:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4316F3858282 for ; Tue, 16 Apr 2024 10:36:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id 988C03858D39 for ; Tue, 16 Apr 2024 10:36:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 988C03858D39 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 988C03858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713263797; cv=none; b=IUhqwO3v1Z1aVcmrk3j0JLzene9aFBTefVuV3jPJuvQkH0/t160Mo0FCORVVmdKVbrBQtn/EGfaRdUCj46WqjoWtrrqvqApJfnMUhlYN95yP2eK+JMFSwPd8pX+0j3QAInvgjoo4V8YoL2UeNVmvQg829hM/FS7hh3iQutlkwUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713263797; c=relaxed/simple; bh=37DELsIqsO4BvzM/BfUqDsz3OsWpYNT38fWjqvmMkGE=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=inDTiJQAA9kNWF+qfBmozEKLUWAYOY3jJcFA5likaCgPLwdzMEI19MRLiGm2ev5e3Lg9V4xq6qjqEAK2RU40tRkm1jOCAyZEC25nNcPOcY9/lHTGfr1KPNdkRJQmYvME1wCmz0MiBTDQ9qVPdm3mPGe34rkGk6tTJrsn85ZeSjw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.5.241] (unknown [10.168.5.241]) (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-out2.suse.de (Postfix) with ESMTPS id 7E71C5D993 for ; Tue, 16 Apr 2024 10:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713263784; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=E9kBj5bglaCvwCXOa0aNBXHr71eDUfvm2zwNMDECl9E=; b=NyE0dSlV0AL8ugyKZz5Lnpm8PW3VqViNsGoXhtmaugfUhXTz9JlEArJSZ/eJNgO61ZPbDl 9Fxhgg6WamfQNSGfTZkcfvBvx4szjh9+yNjk8FwI6C1MRDhoEORp+RaDrmCPFfnI3AXcLz PPue/mBYw5dvFTJB59qmSfn7VyXEKWM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713263784; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=E9kBj5bglaCvwCXOa0aNBXHr71eDUfvm2zwNMDECl9E=; b=fdL4b8a9JfmSby38FscpYI6UBTcytH2JcsUT2cHvOa6KtkVIkEtq+WhDfhBGvX5ziv5GLG fHzmHsfPlYFMhMAQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713263784; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=E9kBj5bglaCvwCXOa0aNBXHr71eDUfvm2zwNMDECl9E=; b=NyE0dSlV0AL8ugyKZz5Lnpm8PW3VqViNsGoXhtmaugfUhXTz9JlEArJSZ/eJNgO61ZPbDl 9Fxhgg6WamfQNSGfTZkcfvBvx4szjh9+yNjk8FwI6C1MRDhoEORp+RaDrmCPFfnI3AXcLz PPue/mBYw5dvFTJB59qmSfn7VyXEKWM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713263784; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=E9kBj5bglaCvwCXOa0aNBXHr71eDUfvm2zwNMDECl9E=; b=fdL4b8a9JfmSby38FscpYI6UBTcytH2JcsUT2cHvOa6KtkVIkEtq+WhDfhBGvX5ziv5GLG fHzmHsfPlYFMhMAQ== Date: Tue, 16 Apr 2024 12:36:24 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/114733 - neg induction fails for 1 element vectors MIME-Version: 1.0 X-Spam-Score: -1.69 X-Spam-Level: X-Spamd-Result: default: False [-1.69 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MISSING_MID(2.50)[]; NEURAL_HAM_LONG(-0.90)[-0.898]; NEURAL_HAM_SHORT(-0.19)[-0.946]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_ONE(0.00)[1]; RCVD_COUNT_ZERO(0.00)[0]; ARC_NA(0.00)[]; MISSING_XM_UA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[] 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 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: <20240416103654.4316F3858282@sourceware.org> The neg induction vectorization code isn't prepared to deal with single element vectors. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. Richard. PR tree-optimization/114733 * tree-vect-loop.cc (vectorizable_nonlinear_induction): Reject neg induction vectorization of single element vectors. * gcc.dg/vect/pr114733.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr114733.c | 20 ++++++++++++++++++++ gcc/tree-vect-loop.cc | 2 ++ 2 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/vect/pr114733.c diff --git a/gcc/testsuite/gcc.dg/vect/pr114733.c b/gcc/testsuite/gcc.dg/vect/pr114733.c new file mode 100644 index 00000000000..219cbf20469 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr114733.c @@ -0,0 +1,20 @@ +/* { dg-additional-options "-O3" } */ + +#include "tree-vect.h" + +long b = 1; +signed char c; +int d[25]; + +int main() +{ + check_vect (); + for (signed char g = 0; g < 8; g += 1) + for (short h = 0; h < 25; h += 2) { + b *= -1; + c ^= d[h]; + } + if (b != 1) + abort (); + return 0; +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index 025319e0cb1..431b3e9492c 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -9685,6 +9685,8 @@ vectorizable_nonlinear_induction (loop_vec_info loop_vinfo, switch (induction_type) { case vect_step_op_neg: + if (maybe_eq (TYPE_VECTOR_SUBPARTS (vectype), 1u)) + return false; if (TREE_CODE (init_expr) != INTEGER_CST && TREE_CODE (init_expr) != REAL_CST) {