From: Fariborz Jahanian Date: Wed, 13 Apr 2005 19:47:30 +0000 (+0000) Subject: Fix result of folding of xor operation on two identical vectors. X-Git-Tag: misc/cutover-cvs2svn~4094 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6bd1354069cc2ccbfa82e79eb2908b370888d0e8;p=thirdparty%2Fgcc.git Fix result of folding of xor operation on two identical vectors. OKed by Roger Sayle. From-SVN: r98107 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f2ac5bb5f139..507bef1e9769 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-04-13 Fariborz Jahanian + + * simplify-rtx.c (simplify_binary_operation_1): Return + scalar or vector of constant 0, depending on the xor's + mode. + 2005-04-13 Dale Johannesen * objc/Make-lang.in (objc-lang.o): Depend on tree-gimple.h. diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index de7ed38afa35..9e02a7a0458a 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1641,7 +1641,7 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode, if (trueop0 == trueop1 && ! side_effects_p (op0) && GET_MODE_CLASS (mode) != MODE_CC) - return const0_rtx; + return CONST0_RTX (mode); /* Canonicalize XOR of the most significant bit to PLUS. */ if ((GET_CODE (op1) == CONST_INT diff --git a/gcc/testsuite/gcc.dg/i386-xorps.c b/gcc/testsuite/gcc.dg/i386-xorps.c new file mode 100644 index 000000000000..86daa794ab44 --- /dev/null +++ b/gcc/testsuite/gcc.dg/i386-xorps.c @@ -0,0 +1,31 @@ +/* { dg-do compile { target i?86-*-* } } */ +/* { dg-options "-Os -msse2" } */ + +typedef float __m128 __attribute__ ((vector_size (16))); + +static __inline __m128 +_mm_mul_ps (__m128 __A, __m128 __B) +{ + return __builtin_ia32_mulps (__A, __B); +} + +static __inline __m128 +_mm_sub_ps (__m128 __A, __m128 __B) +{ + return __builtin_ia32_subps (__A, __B); +} + +__m128 POW_FUNC (__m128 x, __m128 y) +{ + __m128 xmm0 = x, xmm1 = y, xmm2; + + xmm0 = __builtin_ia32_xorps (xmm1, xmm1); + + xmm0 = _mm_mul_ps (xmm0, xmm1); + + xmm0 = _mm_sub_ps (xmm0, xmm1); + + xmm0 = _mm_mul_ps (xmm0, xmm1); + + return xmm0; +}