]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/39943 (wrong conversion from unsigned int to float)
authorUros Bizjak <ubizjak@gmail.com>
Tue, 21 Jul 2009 09:57:46 +0000 (11:57 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Tue, 21 Jul 2009 09:57:46 +0000 (11:57 +0200)
Backport from mainline:
2009-04-29  Richard Guenther  <rguenther@suse.de>

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

testsuite/ChangeLog:

PR target/40809
* gcc.target/i386/pr40809.c: New test.

Backport from mainline:
2009-04-29  Richard Guenther  <rguenther@suse.de>

PR target/39943
* 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.

From-SVN: r149851

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr39943.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/slp-10.c
gcc/testsuite/gcc.dg/vect/slp-11.c
gcc/testsuite/gcc.dg/vect/slp-12b.c
gcc/testsuite/gcc.dg/vect/slp-33.c
gcc/testsuite/gcc.target/i386/pr40809.c [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp

index a221fa9c448793110bd42b8500a43553183a8918..bd7aed79ce6a4895093080d38611e6c3e9dc7e66 100644 (file)
@@ -1,3 +1,12 @@
+2009-07-21  Uros Bizjak  <ubizjak@gmail.com>
+
+       Backport from mainline:
+       2009-04-29  Richard Guenther  <rguenther@suse.de>
+  
+       PR target/39943
+       * config/i386/i386.c (ix86_vectorize_builtin_conversion): Only
+       allow conversion to signed integers.
+
 2009-07-18  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR rtl-optimization/40710
index bb6e968631194de5af2e5deac821365ec0793c66..d5950fec44a59541f8bc9eb1b147fd3df73bae1d 100644 (file)
@@ -21519,7 +21519,9 @@ ix86_veclibabi_acml (enum built_in_function fn, tree type_out, tree type_in)
 static tree
 ix86_vectorize_builtin_conversion (unsigned int code, tree type)
 {
-  if (TREE_CODE (type) != VECTOR_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 61480452166b43a34b8d65fc6d8a23434b00c429..9419deaf2067a01a239a6adabff850764bc83798 100644 (file)
@@ -1,3 +1,21 @@
+2009-07-21  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR target/40809
+       * gcc.target/i386/pr40809.c: New test.
+
+       Backport from mainline:
+       2009-04-29  Richard Guenther  <rguenther@suse.de>
+
+       PR target/39943
+       * 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.
+
 2009-07-14  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/sse-recip-vec.c: Move arrays out of test
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39943.c b/gcc/testsuite/gcc.c-torture/compile/pr39943.c
new file mode 100644 (file)
index 0000000..537ba43
--- /dev/null
@@ -0,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 36dc0cca823a5c296ce72a421bb2bf820cd61f66..9185c7eeb5299cbed35a83df814635328ec08a3b 100644 (file)
@@ -104,11 +104,11 @@ int main (void)
   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 { 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 118818c97bdc6fc36e37ff576b3f70fa1d71f3c4..0568b4610161214c88bb1e1ad53629a080ba419a 100644 (file)
@@ -106,8 +106,8 @@ int main (void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"  { target { vect_strided &&  vect_int_mult } } } } */
-/* { dg-final { scan-tree-dump-times "vectorized 0 loops" 1 "vect"  {target  { ! { vect_int_mult && vect_strided } } } } }  */
+/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect"  { target { { vect_uintfloat_cvt && vect_strided } &&  vect_int_mult } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect"  { target { { { ! vect_uintfloat_cvt } && vect_strided } &&  vect_int_mult } } } } */
 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0  "vect"  } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
   
index 39570016f386a10be8ee7dcf6c43335547dc3a52..fb3058f3c376c05c973c7a5e2c2cfe36bd9278cb 100644 (file)
@@ -1,4 +1,4 @@
-/* { dg-require-effective-target vect_intfloat_cvt } */
+/* { dg-require-effective-target vect_uintfloat_cvt } */
 
 #include <stdarg.h>
 #include <stdio.h>
index 7ee7a0b04207829dce7f0968f44b342d664bdde9..288c748af904e234b27e4407b1b6f8da442fa31c 100644 (file)
@@ -102,11 +102,11 @@ int main (void)
   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 { 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" } } */
   
diff --git a/gcc/testsuite/gcc.target/i386/pr40809.c b/gcc/testsuite/gcc.target/i386/pr40809.c
new file mode 100644 (file)
index 0000000..979b531
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ftree-vectorize -msse2" } */
+
+#include "sse2-check.h"
+
+#define N 8
+
+unsigned int u4[N] = { 4000000000u, 4000000000u, 4000000000u, 4000000000u, 4000000000u, 4000000000u, 4000000000u, 4000000000u };
+float f4[N];
+
+static void
+sse2_test (void)
+{
+  int j;
+
+  for (j = 0; j < N; j++)
+    f4[j] = u4[j];
+
+  /* check results:  */
+  for (j = 0; j < N; j++)
+    if (f4[j] != 4000000000.0)
+      abort ();
+}
index 799cd7eee853fd4de2c30b8d0d13c70974b75aea..8604ab4050f66977b66e3ea37a3ae56a03d6f7c0 100644 (file)
@@ -1121,7 +1121,7 @@ proc check_effective_target_vect_int { } {
     return $et_vect_int_saved
 }
 
-# Return 1 if the target supports int->float conversion 
+# Return 1 if the target supports signed int->float conversion 
 #
 
 proc check_effective_target_vect_intfloat_cvt { } {
@@ -1144,7 +1144,28 @@ proc check_effective_target_vect_intfloat_cvt { } {
 }
 
 
-# Return 1 if the target supports float->int conversion
+# 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 { } {
@@ -1164,6 +1185,26 @@ proc check_effective_target_vect_floatint_cvt { } {
     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 {