Patchwork Fix i386 costs (was: i386: Fix logic error in r188785, PR target/54592)

login
register
mail settings
Submitter Jakub Jelinek
Date Sept. 18, 2012, 12:10 p.m.
Message ID <20120918121043.GX22619@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/184695/
State New
Headers show

Comments

Jakub Jelinek - Sept. 18, 2012, 12:10 p.m.
On Wed, Jun 27, 2012 at 02:36:14PM -0700, Richard Henderson wrote:
> As noticed by Igor Zamyatin.  Committed.

> PR target/53749
>         * config/i386/i386.c (ix86_rtx_costs): Fix typo vs UNITS_PER_WORD
>         in 2012-06-23 change.  Adjust two other DImode tests as well.

This change broke cost computation for vector PLUS/MINUS/AND/IOR/XOR,
the vector modes are all wider than word, but they are now all handled as
double word integer arithmetics.

> ---
>  gcc/ChangeLog          |    6 ++++++
>  gcc/config/i386/i386.c |    8 +++-----
>  2 files changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index edfc649..aae8a4d 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
...
> @@ -32441,7 +32440,7 @@ ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total,
>      case AND:
>      case IOR:
>      case XOR:
> -      if (!TARGET_64BIT && mode == DImode)
> +      if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
>  	{
>  	  *total = (cost->add * 2
>  		    + (rtx_cost (XEXP (x, 0), outer_code, opno, speed)

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2012-09-18  Jakub Jelinek  <jakub@redhat.com>

	PR target/54592
	* config/i386/i386.c (ix86_rtx_costs): Limit > UNITS_PER_WORD
	AND/IOR/XOR cost calculation to MODE_INT class modes.

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



	Jakub
Richard Henderson - Sept. 18, 2012, 3:05 p.m.
On 09/18/2012 05:10 AM, Jakub Jelinek wrote:
> 2012-09-18  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR target/54592
> 	* config/i386/i386.c (ix86_rtx_costs): Limit > UNITS_PER_WORD
> 	AND/IOR/XOR cost calculation to MODE_INT class modes.
> 
> 	* gcc.target/i386/pr54592.c: New test.

Ok.


r~

Patch

--- gcc/config/i386/i386.c.jj	2012-09-13 18:29:08.000000000 +0200
+++ gcc/config/i386/i386.c	2012-09-18 08:55:08.747028184 +0200
@@ -32792,7 +32792,8 @@  ix86_rtx_costs (rtx x, int code_i, int o
     case AND:
     case IOR:
     case XOR:
-      if (GET_MODE_SIZE (mode) > UNITS_PER_WORD)
+      if (GET_MODE_CLASS (mode) == MODE_INT
+	  && GET_MODE_SIZE (mode) > UNITS_PER_WORD)
 	{
 	  *total = (cost->add * 2
 		    + (rtx_cost (XEXP (x, 0), outer_code, opno, speed)
--- gcc/testsuite/gcc.target/i386/pr54592.c.jj	2012-09-18 09:06:09.399013382 +0200
+++ gcc/testsuite/gcc.target/i386/pr54592.c	2012-09-18 09:13:04.482914236 +0200
@@ -0,0 +1,17 @@ 
+/* PR target/54592 */
+/* { dg-do compile } */
+/* { dg-options "-Os -msse2" } */
+/* { dg-require-effective-target sse2 } */
+
+#include <emmintrin.h>
+
+void
+func (__m128i * foo, size_t a, size_t b, int *dst)
+{
+  __m128i x = foo[a];
+  __m128i y = foo[b];
+  __m128i sum = _mm_add_epi32 (x, y);
+  *dst = _mm_cvtsi128_si32 (sum);
+}
+
+/* { dg-final { scan-assembler "paddd\[^\n\r\]*(\\(\[^\n\r\]*\\)|XMMWORD PTR)" } } */