public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix up memset handling in DSE (PR rtl-optimization/69891)
@ 2016-02-26 12:10 Jakub Jelinek
  2016-02-26 12:51 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2016-02-26 12:10 UTC (permalink / raw)
  To: Eric Botcazou, Richard Biener, Jeff Law, Bernd Schmidt; +Cc: gcc-patches

Hi!

As analyzed by Eric, DSE mishandles memset calls if it can't figure out what
the arguments to memset exactly are (it handles only register arguments
right now), or if the second or third arguments are not CONST_INTs.
In that case we don't call record_store, because we don't know what to call
it on; but we need to treat it as a wild store, which is handled by the
clear_rhs_from_active_local_stores () function (which record_store also uses
if it can't figure out what exactly is being overwritten).

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2016-02-26  Jakub Jelinek  <jakub@redhat.com>
	    Eric Botcazou  <ebotcazou@adacore.com>

	PR rtl-optimization/69891
	* dse.c (scan_insn): If we can't figure out memset arguments
	or they are non-constant, call clear_rhs_from_active_local_stores.

	* gcc.target/i386/pr69891.c: New test.

--- gcc/dse.c.jj	2016-01-19 13:32:12.000000000 +0100
+++ gcc/dse.c	2016-02-26 11:03:36.694206088 +0100
@@ -2556,6 +2556,8 @@ scan_insn (bb_info_t bb_info, rtx_insn *
 		      active_local_stores = insn_info;
 		    }
 		}
+	      else
+		clear_rhs_from_active_local_stores ();
 	    }
 	}
       else if (SIBLING_CALL_P (insn) && reload_completed)
--- gcc/testsuite/gcc.target/i386/pr69891.c.jj	2016-02-26 11:09:45.492079225 +0100
+++ gcc/testsuite/gcc.target/i386/pr69891.c	2016-02-26 11:10:58.941058170 +0100
@@ -0,0 +1,30 @@
+/* PR rtl-optimization/69891 */
+/* { dg-do run } */
+/* { dg-options "-O -fno-tree-fre -mstringop-strategy=libcall -Wno-psabi" } */
+/* { dg-additional-options "-mno-sse" { target ia32 } } */
+
+typedef unsigned short A;
+typedef unsigned short B __attribute__ ((vector_size (32)));
+typedef unsigned int C;
+typedef unsigned int D __attribute__ ((vector_size (32)));
+typedef unsigned long long E;
+typedef unsigned long long F __attribute__ ((vector_size (32)));
+
+__attribute__((noinline, noclone)) unsigned
+foo(D a, B b, D c, F d)
+{
+  b /= (B) {1, -c[0]} | 1;
+  c[0] |= 7;
+  a %= c | 1;
+  c ^= c;
+  return a[0] + b[15] + c[0] + d[3];
+}
+
+int
+main ()
+{
+  unsigned x = foo ((D) {}, (B) {}, (D) {}, (F) {});
+  if (x != 0)
+    __builtin_abort ();
+  return 0;
+}

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix up memset handling in DSE (PR rtl-optimization/69891)
  2016-02-26 12:10 [PATCH] Fix up memset handling in DSE (PR rtl-optimization/69891) Jakub Jelinek
@ 2016-02-26 12:51 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2016-02-26 12:51 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Eric Botcazou, Jeff Law, Bernd Schmidt, gcc-patches

On Fri, 26 Feb 2016, Jakub Jelinek wrote:

> Hi!
> 
> As analyzed by Eric, DSE mishandles memset calls if it can't figure out what
> the arguments to memset exactly are (it handles only register arguments
> right now), or if the second or third arguments are not CONST_INTs.
> In that case we don't call record_store, because we don't know what to call
> it on; but we need to treat it as a wild store, which is handled by the
> clear_rhs_from_active_local_stores () function (which record_store also uses
> if it can't figure out what exactly is being overwritten).
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

Ok.

Thanks,
Richard.

> 2016-02-26  Jakub Jelinek  <jakub@redhat.com>
> 	    Eric Botcazou  <ebotcazou@adacore.com>
> 
> 	PR rtl-optimization/69891
> 	* dse.c (scan_insn): If we can't figure out memset arguments
> 	or they are non-constant, call clear_rhs_from_active_local_stores.
> 
> 	* gcc.target/i386/pr69891.c: New test.
> 
> --- gcc/dse.c.jj	2016-01-19 13:32:12.000000000 +0100
> +++ gcc/dse.c	2016-02-26 11:03:36.694206088 +0100
> @@ -2556,6 +2556,8 @@ scan_insn (bb_info_t bb_info, rtx_insn *
>  		      active_local_stores = insn_info;
>  		    }
>  		}
> +	      else
> +		clear_rhs_from_active_local_stores ();
>  	    }
>  	}
>        else if (SIBLING_CALL_P (insn) && reload_completed)
> --- gcc/testsuite/gcc.target/i386/pr69891.c.jj	2016-02-26 11:09:45.492079225 +0100
> +++ gcc/testsuite/gcc.target/i386/pr69891.c	2016-02-26 11:10:58.941058170 +0100
> @@ -0,0 +1,30 @@
> +/* PR rtl-optimization/69891 */
> +/* { dg-do run } */
> +/* { dg-options "-O -fno-tree-fre -mstringop-strategy=libcall -Wno-psabi" } */
> +/* { dg-additional-options "-mno-sse" { target ia32 } } */
> +
> +typedef unsigned short A;
> +typedef unsigned short B __attribute__ ((vector_size (32)));
> +typedef unsigned int C;
> +typedef unsigned int D __attribute__ ((vector_size (32)));
> +typedef unsigned long long E;
> +typedef unsigned long long F __attribute__ ((vector_size (32)));
> +
> +__attribute__((noinline, noclone)) unsigned
> +foo(D a, B b, D c, F d)
> +{
> +  b /= (B) {1, -c[0]} | 1;
> +  c[0] |= 7;
> +  a %= c | 1;
> +  c ^= c;
> +  return a[0] + b[15] + c[0] + d[3];
> +}
> +
> +int
> +main ()
> +{
> +  unsigned x = foo ((D) {}, (B) {}, (D) {}, (F) {});
> +  if (x != 0)
> +    __builtin_abort ();
> +  return 0;
> +}
> 
> 	Jakub
> 
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-26 12:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-26 12:10 [PATCH] Fix up memset handling in DSE (PR rtl-optimization/69891) Jakub Jelinek
2016-02-26 12:51 ` 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).