]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PR100843] store by mult pieces: punt on max_len < min_len
authorAlexandre Oliva <oliva@adacore.com>
Wed, 15 Dec 2021 05:22:33 +0000 (02:22 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Wed, 15 Dec 2021 05:22:33 +0000 (02:22 -0300)
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.

gcc/builtins.c
gcc/testsuite/gcc.dg/pr100843.c [new file with mode: 0644]

index 03829c03a5a11677cb9652652d441a3fd3f63aa2..304d87dafb750b5dc36af21cec9e53439a01cefb 100644 (file)
@@ -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 (file)
index 0000000..695a2ec
--- /dev/null
@@ -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);
+}