From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 56A36385781D; Tue, 30 Nov 2021 08:17:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 56A36385781D 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 r12-5593] middle-end/103485 - fix conversion kind for vectors X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 930e7637828b6c6da7ff33ff3bd20c5c4c9164e7 X-Git-Newrev: e2521cd2d26661cfcfceaabf9bd281ef316fd3fc Message-Id: <20211130081705.56A36385781D@sourceware.org> Date: Tue, 30 Nov 2021 08:17:05 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Nov 2021 08:17:05 -0000 https://gcc.gnu.org/g:e2521cd2d26661cfcfceaabf9bd281ef316fd3fc commit r12-5593-ge2521cd2d26661cfcfceaabf9bd281ef316fd3fc Author: Richard Biener Date: Tue Nov 30 08:19:24 2021 +0100 middle-end/103485 - fix conversion kind for vectors This makes sure to use a VIEW_CONVERT_EXPR for converting vector signedness in the -((int)x >> (prec - 1)) to (unsigned)x >> (prec - 1) simplification. 2021-11-30 Richard Biener PR middle-end/103485 * match.pd (-((int)x >> (prec - 1)) to (unsigned)x >> (prec - 1)): Use VIEW_CONVERT_EXPR for vectors. * gcc.dg/pr103485.c: New testcase. Diff: --- gcc/match.pd | 4 +++- gcc/testsuite/gcc.dg/pr103485.c | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/match.pd b/gcc/match.pd index e14f97ee1cd..d467a1c4e45 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -1611,7 +1611,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (with { tree stype = TREE_TYPE (@0); tree ntype = TYPE_UNSIGNED (stype) ? signed_type_for (stype) : unsigned_type_for (stype); } - (convert (rshift:ntype (convert:ntype @0) @1))))) + (if (VECTOR_TYPE_P (type)) + (view_convert (rshift (view_convert:ntype @0) @1)) + (convert (rshift (convert:ntype @0) @1)))))) /* Try to fold (type) X op CST -> (type) (X op ((type-x) CST)) when profitable. diff --git a/gcc/testsuite/gcc.dg/pr103485.c b/gcc/testsuite/gcc.dg/pr103485.c new file mode 100644 index 00000000000..1afa9286924 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr103485.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ + +int foo_v256u128_0; +unsigned __attribute__((__vector_size__ (sizeof(unsigned) * 8))) foo_v256u8_0; + +void +foo (void) +{ + foo_v256u8_0 -= (foo_v256u8_0 >> sizeof (foo_v256u8_0) - 1) + foo_v256u128_0; +}