diff mbox

[PR77718]

Message ID 1475077898.9666.31.camel@linux.vnet.ibm.com
State New
Headers show

Commit Message

Aaron Sawdey Sept. 28, 2016, 3:51 p.m. UTC
This patch that Bernd put in PR77718 seems to be fine. Bootstrap and
regtest done on powerpc64le, no new failures. Ok for trunk?

2016-09-28  Bernd Schmidt  <bschmidt@redhat.com>

	* builtins.c (expand_builtin_memcmp): don't swap args unless
	result is only being compared with zero.

Comments

Richard Biener Sept. 29, 2016, 8:27 a.m. UTC | #1
On Wed, Sep 28, 2016 at 5:51 PM, Aaron Sawdey
<acsawdey@linux.vnet.ibm.com> wrote:
> This patch that Bernd put in PR77718 seems to be fine. Bootstrap and
> regtest done on powerpc64le, no new failures. Ok for trunk?

Ok.

Richard.

> 2016-09-28  Bernd Schmidt  <bschmidt@redhat.com>
>
>         * builtins.c (expand_builtin_memcmp): don't swap args unless
>         result is only being compared with zero.
>
> Index: builtins.c
> ===================================================================
> --- builtins.c  (revision 240511)
> +++ builtins.c  (working copy)
> @@ -3707,11 +3707,13 @@ expand_builtin_memcmp (tree exp, rtx tar
>
>    by_pieces_constfn constfn = NULL;
>
> -  const char *src_str = c_getstr (arg1);
> -  if (src_str == NULL)
> -    src_str = c_getstr (arg2);
> -  else
> -    std::swap (arg1_rtx, arg2_rtx);
> +  const char *src_str = c_getstr (arg2);
> +  if (result_eq && src_str == NULL)
> +    {
> +      src_str = c_getstr (arg1);
> +      if (src_str != NULL)
> +       std::swap (arg1_rtx, arg2_rtx);
> +    }
>
>    /* If SRC is a string constant and block move would be done
>       by pieces, we can avoid loading the string from memory
>
> --
> Aaron Sawdey, Ph.D.  acsawdey@linux.vnet.ibm.com
> 050-2/C113  (507) 253-7520 home: 507/263-0782
> IBM Linux Technology Center - PPC Toolchain
>
diff mbox

Patch

Index: builtins.c
===================================================================
--- builtins.c	(revision 240511)
+++ builtins.c	(working copy)
@@ -3707,11 +3707,13 @@  expand_builtin_memcmp (tree exp, rtx tar
 
   by_pieces_constfn constfn = NULL;
 
-  const char *src_str = c_getstr (arg1);
-  if (src_str == NULL)
-    src_str = c_getstr (arg2);
-  else
-    std::swap (arg1_rtx, arg2_rtx);
+  const char *src_str = c_getstr (arg2);
+  if (result_eq && src_str == NULL)
+    {
+      src_str = c_getstr (arg1);
+      if (src_str != NULL)
+	std::swap (arg1_rtx, arg2_rtx);
+    }
 
   /* If SRC is a string constant and block move would be done
      by pieces, we can avoid loading the string from memory