public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Optimize vector mode | 0 and ^ 0 (PR rtl-optimization/45739)
@ 2010-09-22  9:59 Jakub Jelinek
  2010-09-22 10:11 ` Richard Henderson
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2010-09-22  9:59 UTC (permalink / raw)
  To: gcc-patches

Hi!

This patch allows optimizing vector | 0 or ^ 0 similarly to similar
scalar expressions.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2010-09-21  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/45739
	* simplify-rtx.c (simplify_binary_operation_1): Optimize even
	vector mode | CONST0_RTX (mode) and ^ CONST0_RTX (mode).

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

--- gcc/simplify-rtx.c.jj	2010-09-09 10:16:30.000000000 +0200
+++ gcc/simplify-rtx.c	2010-09-21 13:26:53.000000000 +0200
@@ -2260,7 +2260,7 @@ simplify_binary_operation_1 (enum rtx_co
       break;
 
     case IOR:
-      if (trueop1 == const0_rtx)
+      if (trueop1 == CONST0_RTX (mode))
 	return op0;
       if (CONST_INT_P (trueop1)
 	  && ((INTVAL (trueop1) & GET_MODE_MASK (mode))
@@ -2402,7 +2402,7 @@ simplify_binary_operation_1 (enum rtx_co
       break;
 
     case XOR:
-      if (trueop1 == const0_rtx)
+      if (trueop1 == CONST0_RTX (mode))
 	return op0;
       if (CONST_INT_P (trueop1)
 	  && ((INTVAL (trueop1) & GET_MODE_MASK (mode))
--- gcc/testsuite/gcc.target/i386/pr45739.c.jj	2010-09-21 13:44:05.000000000 +0200
+++ gcc/testsuite/gcc.target/i386/pr45739.c	2010-09-21 13:43:54.000000000 +0200
@@ -0,0 +1,24 @@
+/* PR rtl-optimization/45739 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2" } */
+
+#include <emmintrin.h>
+
+__m128i var;
+
+void
+foo (void)
+{
+  __m128i zero = _mm_setzero_si128 ();
+  var = _mm_xor_si128 (zero, var);
+}
+
+void
+bar (void)
+{
+  __m128i zero = _mm_setzero_si128 ();
+  var = _mm_or_si128 (var, zero);
+}
+
+/* { dg-final { scan-assembler-not "pxor" } } */
+/* { dg-final { scan-assembler-not "por" } } */

	Jakub

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

* Re: [PATCH] Optimize vector mode | 0 and ^ 0 (PR rtl-optimization/45739)
  2010-09-22  9:59 [PATCH] Optimize vector mode | 0 and ^ 0 (PR rtl-optimization/45739) Jakub Jelinek
@ 2010-09-22 10:11 ` Richard Henderson
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2010-09-22 10:11 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On 09/21/2010 03:44 PM, Jakub Jelinek wrote:
> 	PR rtl-optimization/45739
> 	* simplify-rtx.c (simplify_binary_operation_1): Optimize even
> 	vector mode | CONST0_RTX (mode) and ^ CONST0_RTX (mode).
> 
> 	* gcc.target/i386/pr45739.c: New test.

Ok.


r~

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

end of thread, other threads:[~2010-09-21 23:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-22  9:59 [PATCH] Optimize vector mode | 0 and ^ 0 (PR rtl-optimization/45739) Jakub Jelinek
2010-09-22 10:11 ` Richard Henderson

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).