]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/77718 (expand_builtin_memcmp swaps args)
authorJakub Jelinek <jakub@gcc.gnu.org>
Wed, 9 Nov 2016 16:21:45 +0000 (17:21 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 9 Nov 2016 16:21:45 +0000 (17:21 +0100)
PR target/77718
* builtins.c (expand_builtin_memcmp): Formatting fix.

* gcc.c-torture/execute/pr77718.c: New test.

From-SVN: r242007

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr77718.c [new file with mode: 0644]

index 355148b2c724cdce625b0757a1676cc1d3c43512..d5616524c0df49c4fde41197557143143567067d 100644 (file)
@@ -1,5 +1,8 @@
 2016-11-09  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/77718
+       * builtins.c (expand_builtin_memcmp): Formatting fix.
+
        * flag-types.h (enum sanitize_code): Add SANITIZE_SHIFT_BASE
        and SANITIZE_SHIFT_EXPONENT, change SANITIZE_SHIFT to bitwise
        or of them, renumber other enumerators.
 
 2016-09-29  Bernd Schmidt  <bschmidt@redhat.com>
 
-       * builtins.c (expand_builtin_memcmp): don't swap args unless
+       PR target/77718
+       * builtins.c (expand_builtin_memcmp): Don't swap args unless
        result is only being compared with zero.
 
 2016-09-29  Marek Polacek  <polacek@redhat.com>
index cc711a0f8430de41f77d1ff2b10abc9560a1025a..3ac2d44148440b124559ba7cd3de483b7a74b72d 100644 (file)
@@ -3754,7 +3754,7 @@ expand_builtin_memcmp (tree exp, rtx target, bool result_eq)
     {
       src_str = c_getstr (arg1);
       if (src_str != NULL)
-       std::swap (arg1_rtx, arg2_rtx);
+       std::swap (arg1_rtx, arg2_rtx);
     }
 
   /* If SRC is a string constant and block move would be done
index dd221bbb136bb7426402ceb5af1798c9902fa516..7a3b6c5ffc608e4619c970e4b93ea72294156f06 100644 (file)
@@ -1,5 +1,8 @@
 2016-11-09  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/77718
+       * gcc.c-torture/execute/pr77718.c: New test.
+
        * gcc.dg/ubsan/c99-shift-3.c: New test.
        * gcc.dg/ubsan/c99-shift-4.c: New test.
        * gcc.dg/ubsan/c99-shift-5.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr77718.c b/gcc/testsuite/gcc.c-torture/execute/pr77718.c
new file mode 100644 (file)
index 0000000..a76effe
--- /dev/null
@@ -0,0 +1,25 @@
+/* PR middle-end/77718 */
+
+char a[64] __attribute__((aligned (8)));
+
+__attribute__((noinline, noclone)) int
+foo (void)
+{
+  return __builtin_memcmp ("bbbbbb", a, 6);
+}
+
+__attribute__((noinline, noclone)) int
+bar (void)
+{
+  return __builtin_memcmp (a, "bbbbbb", 6);
+}
+
+int
+main ()
+{
+  __builtin_memset (a, 'a', sizeof (a));
+  if (((foo () < 0) ^ ('a' > 'b'))
+      || ((bar () < 0) ^ ('a' < 'b')))
+    __builtin_abort ();
+  return 0;
+}