This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][RFC] Fix PR39943, wrong code with vectorized conversion on x86_64


On Tue, 28 Apr 2009, Uros Bizjak wrote:

> Richard Guenther wrote:
> > This fixes the ICE on 177.mesa caused by type checking which catched
> > the wrong-code issue that we are happily doing vectorized
> > float -> unsigned and unsigned -> float conversions with the SSE
> > cvtdq2ps and cvttps2dq instructions which only work with signed
> > integer value ranges.  Oops.
> > 
> > ...
> > 
> > because they all use conversions to/from unsigned ints.  Ira - do you
> > prefer adding another vector capability, vect_uintfloat_cvt, here
> > or placing strategic XFAILs in the tests?  Are there corresponding
> > tests for signed int conversions?  Do ppc and ia64 really handle this
> > cases correctly?
> > 
> > I'll bootstrap / test this soon.  Uros, is the backend change ok?
> >   
> 
> Yes, backend change is OK for all branches.

This implements the testsuite harness extensions.  Janis, are the
testsuite changes ok for trunk (if re-testing succeeds)?

Thanks,
Richard.

2009-04-28  Richard Guenther  <rguenther@suse.de>

	PR target/39943
	* config/i386/i386.c (ix86_vectorize_builtin_conversion): Only
	allow conversion to signed integers.

	* lib/target-supports.exp (check_effective_target_vect_uintfloat_cvt):
	New.
	(check_effective_target_vect_floatuint_cvt): Likewise.
	* gcc.dg/vect/slp-10.c: Adjust.
	* gcc.dg/vect/slp-11.c: Adjust.
	* gcc.dg/vect/slp-12b.c: Adjust.
	* gcc.dg/vect/slp-33.c: Adjust.
	* gcc.c-torture/compile/pr39943.c: New testcase.

Index: gcc/config/i386/i386.c
===================================================================
*** gcc/config/i386/i386.c.orig	2009-04-29 10:16:56.000000000 +0200
--- gcc/config/i386/i386.c	2009-04-29 10:17:54.000000000 +0200
*************** ix86_veclibabi_acml (enum built_in_funct
*** 25639,25645 ****
  static tree
  ix86_vectorize_builtin_conversion (unsigned int code, tree type)
  {
!   if (TREE_CODE (type) != VECTOR_TYPE)
      return NULL_TREE;
  
    switch (code)
--- 25639,25647 ----
  static tree
  ix86_vectorize_builtin_conversion (unsigned int code, tree type)
  {
!   if (TREE_CODE (type) != VECTOR_TYPE
!       /* There are only conversions from/to signed integers.  */
!       || TYPE_UNSIGNED (TREE_TYPE (type)))
      return NULL_TREE;
  
    switch (code)
Index: gcc/testsuite/gcc.c-torture/compile/pr39943.c
===================================================================
*** /dev/null	1970-01-01 00:00:00.000000000 +0000
--- gcc/testsuite/gcc.c-torture/compile/pr39943.c	2009-04-29 10:17:54.000000000 +0200
***************
*** 0 ****
--- 1,7 ----
+ void gl_fog_index_pixels(float f, unsigned int n, unsigned int index[])
+ { 
+   unsigned int i;
+   for (i=0; i<n; i++) 
+     index[i] = (unsigned int) ((float) index[i] + (1.0F-f));
+ }
+ 
Index: gcc/testsuite/gcc.dg/vect/slp-10.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/slp-10.c.orig	2007-11-30 13:59:34.000000000 +0100
--- gcc/testsuite/gcc.dg/vect/slp-10.c	2009-04-29 10:21:48.000000000 +0200
*************** int main (void)
*** 104,114 ****
    return 0;
  }
  
! /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"  {target {vect_intfloat_cvt && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect"  {target {{! { vect_intfloat_cvt}} && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect"  {target {{! { vect_intfloat_cvt}} && { ! {vect_int_mult}}} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" {target {vect_intfloat_cvt && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect"  {target {{! { vect_intfloat_cvt}} && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect"  {target {{! { vect_intfloat_cvt}} && { ! {vect_int_mult}}} } } } */
  /* { dg-final { cleanup-tree-dump "vect" } } */
    
--- 104,114 ----
    return 0;
  }
  
! /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"  {target {vect_uintfloat_cvt && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect"  {target {{! { vect_uintfloat_cvt}} && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect"  {target {{! { vect_uintfloat_cvt}} && { ! {vect_int_mult}}} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" {target {vect_uintfloat_cvt && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect"  {target {{! { vect_uintfloat_cvt}} && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect"  {target {{! { vect_uintfloat_cvt}} && { ! {vect_int_mult}}} } } } */
  /* { dg-final { cleanup-tree-dump "vect" } } */
    
Index: gcc/testsuite/gcc.dg/vect/slp-11.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/slp-11.c.orig	2008-08-27 16:56:58.000000000 +0200
--- gcc/testsuite/gcc.dg/vect/slp-11.c	2009-04-29 10:22:23.000000000 +0200
*************** int main (void)
*** 106,113 ****
    return 0;
  }
  
! /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"  { target { { vect_intfloat_cvt && vect_strided_wide } &&  vect_int_mult } } } } */
! /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect"  { target { { { ! vect_intfloat_cvt } && vect_strided_wide } &&  vect_int_mult } } } } */
  /* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect"  {target  { ! { vect_int_mult && vect_strided_wide } } } } }  */
  /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0  "vect"  } } */
  /* { dg-final { cleanup-tree-dump "vect" } } */
--- 106,113 ----
    return 0;
  }
  
! /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"  { target { { vect_uintfloat_cvt && vect_strided_wide } &&  vect_int_mult } } } } */
! /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect"  { target { { { ! vect_uintfloat_cvt } && vect_strided_wide } &&  vect_int_mult } } } } */
  /* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect"  {target  { ! { vect_int_mult && vect_strided_wide } } } } }  */
  /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0  "vect"  } } */
  /* { dg-final { cleanup-tree-dump "vect" } } */
Index: gcc/testsuite/gcc.dg/vect/slp-12b.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/slp-12b.c.orig	2008-08-19 10:58:44.000000000 +0200
--- gcc/testsuite/gcc.dg/vect/slp-12b.c	2009-04-29 10:30:15.000000000 +0200
***************
*** 1,4 ****
! /* { dg-require-effective-target vect_intfloat_cvt } */
  
  #include <stdarg.h>
  #include <stdio.h>
--- 1,4 ----
! /* { dg-require-effective-target vect_uintfloat_cvt } */
  
  #include <stdarg.h>
  #include <stdio.h>
Index: gcc/testsuite/gcc.dg/vect/slp-33.c
===================================================================
*** gcc/testsuite/gcc.dg/vect/slp-33.c.orig	2007-11-30 13:59:34.000000000 +0100
--- gcc/testsuite/gcc.dg/vect/slp-33.c	2009-04-29 10:25:36.000000000 +0200
*************** int main (void)
*** 102,112 ****
    return 0;
  }
  
! /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"  {target {vect_intfloat_cvt && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect"  {target {{! { vect_intfloat_cvt}} && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect"  {target {{! { vect_intfloat_cvt}} && {! {vect_int_mult}}} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" {target {vect_intfloat_cvt && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect"  {target {{! { vect_intfloat_cvt}} && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect"  {target {{! { vect_intfloat_cvt}} && {! {vect_int_mult}}} } } } */
  /* { dg-final { cleanup-tree-dump "vect" } } */
    
--- 102,112 ----
    return 0;
  }
  
! /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"  {target {vect_uintfloat_cvt && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect"  {target {{! { vect_uintfloat_cvt}} && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect"  {target {{! { vect_uintfloat_cvt}} && {! {vect_int_mult}}} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 3 "vect" {target {vect_uintfloat_cvt && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 2 "vect"  {target {{! { vect_uintfloat_cvt}} && vect_int_mult} } } } */
! /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect"  {target {{! { vect_uintfloat_cvt}} && {! {vect_int_mult}}} } } } */
  /* { dg-final { cleanup-tree-dump "vect" } } */
    
Index: gcc/testsuite/lib/target-supports.exp
===================================================================
*** gcc/testsuite/lib/target-supports.exp.orig	2009-04-29 10:09:23.000000000 +0200
--- gcc/testsuite/lib/target-supports.exp	2009-04-29 10:20:14.000000000 +0200
*************** proc check_effective_target_vect_int { }
*** 1338,1344 ****
      return $et_vect_int_saved
  }
  
! # Return 1 if the target supports int->float conversion 
  #
  
  proc check_effective_target_vect_intfloat_cvt { } {
--- 1338,1344 ----
      return $et_vect_int_saved
  }
  
! # Return 1 if the target supports signed int->float conversion 
  #
  
  proc check_effective_target_vect_intfloat_cvt { } {
*************** proc check_effective_target_vect_intfloa
*** 1361,1367 ****
  }
  
  
! # Return 1 if the target supports float->int conversion
  #
  
  proc check_effective_target_vect_floatint_cvt { } {
--- 1361,1388 ----
  }
  
  
! # Return 1 if the target supports unsigned int->float conversion 
! #
! 
! proc check_effective_target_vect_uintfloat_cvt { } {
!     global et_vect_uintfloat_cvt_saved
! 
!     if [info exists et_vect_uintfloat_cvt_saved] {
!         verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
!     } else {
!         set et_vect_uintfloat_cvt_saved 0
!         if { ([istarget powerpc*-*-*]
! 	      && ![istarget powerpc-*-linux*paired*]) } {
!            set et_vect_uintfloat_cvt_saved 1
!         }
!     }
! 
!     verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
!     return $et_vect_uintfloat_cvt_saved
! }
! 
! 
! # Return 1 if the target supports signed float->int conversion
  #
  
  proc check_effective_target_vect_floatint_cvt { } {
*************** proc check_effective_target_vect_floatin
*** 1383,1388 ****
--- 1404,1429 ----
      return $et_vect_floatint_cvt_saved
  }
  
+ # Return 1 if the target supports unsigned float->int conversion
+ #
+ 
+ proc check_effective_target_vect_floatuint_cvt { } {
+     global et_vect_floatuint_cvt_saved
+ 
+     if [info exists et_vect_floatuint_cvt_saved] {
+         verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
+     } else {
+         set et_vect_floatuint_cvt_saved 0
+         if { ([istarget powerpc*-*-*]
+ 	      && ![istarget powerpc-*-linux*paired*]) } {
+            set et_vect_floatuint_cvt_saved 1
+         }
+     }
+ 
+     verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
+     return $et_vect_floatuint_cvt_saved
+ }
+ 
  # Return 1 is this is an arm target using 32-bit instructions
  proc check_effective_target_arm32 { } {
      return [check_no_compiler_messages arm32 assembly {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]