From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 553723858C62; Tue, 24 Jan 2023 14:27:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 553723858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674570438; bh=II13NEgwdjH/bweQ592bvonuPDP0cVGDYIqCljxON0o=; h=From:To:Subject:Date:From; b=qZUsqp9CuFnrbfp62udJ4nVDtE6FDqonv3+THcKZMyLp/q8czERzap2OamGN8cchC zF3uF1HYXrOeIK3xtbZ+t/q6/EUsmbKk7Z3hMDg16bonSVGKWT9/2ICf6rSA6FHP5O mPaS28N+Fz4rIDrTt9HzDK59wSskBJ5PXKI3wAjI= 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-9062] tree-optimization/107554 - fix ICE in stlen optimization X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 193f7e62815b4089dfaed4c2bd34fd4f10209e27 X-Git-Newrev: ca8b8191983d1a211a718b39ca07e35b8c626416 Message-Id: <20230124142718.553723858C62@sourceware.org> Date: Tue, 24 Jan 2023 14:27:18 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ca8b8191983d1a211a718b39ca07e35b8c626416 commit r12-9062-gca8b8191983d1a211a718b39ca07e35b8c626416 Author: Richard Biener Date: Fri Nov 11 14:28:52 2022 +0100 tree-optimization/107554 - fix ICE in stlen optimization The following fixes a wrongly typed variable causing an ICE. PR tree-optimization/107554 * tree-ssa-strlen.cc (strlen_pass::count_nonzero_bytes): Use unsigned HOST_WIDE_INT type for the strlen. * gcc.dg/pr107554.c: New testcase. Co-Authored-By: Nikita Voronov (cherry picked from commit 81de4037454275f8ed6d858fbc129e832c6147ef) Diff: --- gcc/testsuite/gcc.dg/pr107554.c | 12 ++++++++++++ gcc/tree-ssa-strlen.cc | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/pr107554.c b/gcc/testsuite/gcc.dg/pr107554.c new file mode 100644 index 00000000000..8bbe6b07ae9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr107554.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O -foptimize-strlen" } */ + +#define ELEMS 0x40000000 + +int a[ELEMS]; +int b[ELEMS]; + +int main() +{ + __builtin_memcpy(a, b, ELEMS*sizeof(int)); +} diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc index 2d7db6da5bc..cb7ccb41d73 100644 --- a/gcc/tree-ssa-strlen.cc +++ b/gcc/tree-ssa-strlen.cc @@ -4700,7 +4700,7 @@ strlen_pass::count_nonzero_bytes (tree exp, gimple *stmt, /* Compute the number of leading nonzero bytes in the representation and update the minimum and maximum. */ - unsigned n = prep ? strnlen (prep, nbytes) : nbytes; + unsigned HOST_WIDE_INT n = prep ? strnlen (prep, nbytes) : nbytes; if (n < lenrange[0]) lenrange[0] = n;