public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5983] [PR100843] store by mult pieces: punt on max_len < min_len
@ 2021-12-15 5:25 Alexandre Oliva
0 siblings, 0 replies; only message in thread
From: Alexandre Oliva @ 2021-12-15 5:25 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c95a9f1ee7ebd461cbced455271a993bae3a42b6
commit r12-5983-gc95a9f1ee7ebd461cbced455271a993bae3a42b6
Author: Alexandre Oliva <oliva@adacore.com>
Date: Wed Dec 15 02:22:33 2021 -0300
[PR100843] store by mult pieces: punt on max_len < min_len
The testcase confuses the code that detects min and max len for the
memset, so max_len ends up less than min_len. That shouldn't be
possible, but the testcase requires us to handle this case.
The store-by-mult-pieces algorithm actually relies on min and max
lengths, so if we find them to be inconsistent, the best we can do is
punting.
for gcc/ChangeLog
PR middle-end/100843
* builtins.c (try_store_by_multiple_pieces): Fail if min_len
is greater than max_len.
for gcc/testsuite/ChangeLog
PR middle-end/100843
* gcc.dg/pr100843.c: New.
Diff:
---
gcc/builtins.c | 3 ++-
gcc/testsuite/gcc.dg/pr100843.c | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 03829c03a5a..304d87dafb7 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -3963,7 +3963,8 @@ try_store_by_multiple_pieces (rtx to, rtx len, unsigned int ctz_len,
else if (max_len == min_len)
blksize = max_len;
else
- gcc_unreachable ();
+ /* Huh, max_len < min_len? Punt. See pr100843.c. */
+ return false;
if (min_len >= blksize)
{
min_len -= blksize;
diff --git a/gcc/testsuite/gcc.dg/pr100843.c b/gcc/testsuite/gcc.dg/pr100843.c
new file mode 100644
index 00000000000..695a2ec3f68
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100843.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -w" } */
+
+char c;
+void *memset();
+void test_integer_conversion_memset(void *d) {
+ memset(d, '\0', c);
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-12-15 5:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-15 5:25 [gcc r12-5983] [PR100843] store by mult pieces: punt on max_len < min_len Alexandre Oliva
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).