From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id B7FD13846062; Fri, 3 May 2024 13:55:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B7FD13846062 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714744509; bh=RYy+iVbSHkPvMeVWXOYGnRyMOGTS9WUe+chaiXuQTOY=; h=From:To:Subject:Date:From; b=dFUhasaIGAHQ/D5QRghGFDICoOtKROZEbN0V+4YjmtQGzXIZ+ElSaf3+c9QK9XB1E 5koGHbZDErKIvn50PB9mwfRPJP1DTTXp9dtAT/zDS+VHY4akqOzruAK48AwqriwkCx gnwstBSkBv0+My7/2VTDqffVsOGeVkrH8RFZVHyA= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-8680] tree-optimization/114733 - neg induction fails for 1 element vectors X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: a676581ddc49a6ead8edced7bb4b92aeceebde56 X-Git-Newrev: b3f9f10e03c570074a517dcfe9df8d3eeddd6aca Message-Id: <20240503135509.B7FD13846062@sourceware.org> Date: Fri, 3 May 2024 13:55:09 +0000 (GMT) List-Id: https://gcc.gnu.org/g:b3f9f10e03c570074a517dcfe9df8d3eeddd6aca commit r13-8680-gb3f9f10e03c570074a517dcfe9df8d3eeddd6aca Author: Richard Biener Date: Tue Apr 16 10:46:03 2024 +0200 tree-optimization/114733 - neg induction fails for 1 element vectors The neg induction vectorization code isn't prepared to deal with single element vectors. 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. (cherry picked from commit 45a41ace55d0ffb1097e374868242329788ec82a) Diff: --- gcc/testsuite/gcc.dg/vect/pr114733.c | 20 ++++++++++++++++++++ gcc/tree-vect-loop.cc | 2 ++ 2 files changed, 22 insertions(+) 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 31ced32126e..73caeb283e3 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -8944,6 +8944,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) {