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

login
register
mail settings
Submitter Jakub Jelinek
Date Sept. 21, 2010, 10:44 p.m.
Message ID <20100921224451.GV1269@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/65387/
State New
Headers show

Comments

Jakub Jelinek - Sept. 21, 2010, 10:44 p.m.
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
Richard Henderson - Sept. 21, 2010, 11:19 p.m.
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~

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