This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Optimize vector mode | 0 and ^ 0 (PR rtl-optimization/45739)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 22 Sep 2010 00:44:51 +0200
- Subject: [PATCH] Optimize vector mode | 0 and ^ 0 (PR rtl-optimization/45739)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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