diff mbox

Optimize vector mode | 0 and ^ 0 (PR rtl-optimization/45739)

Message ID 20100921224451.GV1269@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Sept. 21, 2010, 10:44 p.m. UTC
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.


	Jakub

Comments

Richard Henderson Sept. 21, 2010, 11:19 p.m. UTC | #1
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~
diff mbox

Patch

--- 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" } } */