* [PATCH] tree-optimization/107554 - fix ICE in stlen optimization
@ 2022-11-11 14:36 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-11-11 14:36 UTC (permalink / raw)
To: gcc-patches
The following fixes a wrongly typed variable causing an ICE.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
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 <nik_1357@mail.ru>
---
gcc/testsuite/gcc.dg/pr107554.c | 12 ++++++++++++
gcc/tree-ssa-strlen.cc | 2 +-
2 files changed, 13 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/pr107554.c
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 b87c7c7ce1f..abec225566d 100644
--- a/gcc/tree-ssa-strlen.cc
+++ b/gcc/tree-ssa-strlen.cc
@@ -4735,7 +4735,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;
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-11 14:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11 14:36 [PATCH] tree-optimization/107554 - fix ICE in stlen optimization Richard Biener
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).