public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-10483] tree-optimization/107554 - fix ICE in stlen optimization
Date: Tue, 24 Jan 2023 15:22:55 +0000 (GMT)	[thread overview]
Message-ID: <20230124152255.CD70F3858408@sourceware.org> (raw)

https://gcc.gnu.org/g:23a9270c999a24cdc0b716e832e5f16bb13db891

commit r11-10483-g23a9270c999a24cdc0b716e832e5f16bb13db891
Author: Richard Biener <rguenther@suse.de>
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.c (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 <nik_1357@mail.ru>
    (cherry picked from commit 81de4037454275f8ed6d858fbc129e832c6147ef)

Diff:
---
 gcc/testsuite/gcc.dg/pr107554.c | 12 ++++++++++++
 gcc/tree-ssa-strlen.c           |  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.c b/gcc/tree-ssa-strlen.c
index cccd4a06771..9f317a190ee 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -4523,7 +4523,7 @@ count_nonzero_bytes (tree exp, unsigned HOST_WIDE_INT offset,
 
   /* 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;

                 reply	other threads:[~2023-01-24 15:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230124152255.CD70F3858408@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).