public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-10013] tree-optimization/105250 - adjust fold_convertible_p PR105140 fix
@ 2022-05-19 14:02 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-05-19 14:02 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0be87cc23d0b0e07656e94137978971555bebbb3

commit r11-10013-g0be87cc23d0b0e07656e94137978971555bebbb3
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Apr 13 08:52:57 2022 +0200

    tree-optimization/105250 - adjust fold_convertible_p PR105140 fix
    
    The following reverts the original PR105140 fix and goes for instead
    applying the additional fold_convert constraint for VECTOR_TYPE
    conversions also to fold_convertible_p.  I did not try sanitizing
    all of this at this point.
    
    2022-04-13  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/105250
            * fold-const.c (fold_convertible_p): Revert
            r12-7979-geaaf77dd85c333, instead check for size equality
            of the vector types involved.
    
            * gcc.dg/pr105250.c: New testcase.
    
    (cherry picked from commit 4e892de6774f86540d36385701aa7b0a2bba5155)

Diff:
---
 gcc/fold-const.c                |  7 +++----
 gcc/testsuite/gcc.dg/pr105250.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 4657bf28f95..572d70b039d 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2350,13 +2350,12 @@ build_zero_vector (tree type)
   return build_vector_from_val (type, t);
 }
 
-/* Returns true, if ARG, an operand or a type, is convertible to TYPE
-   using a NOP_EXPR.  */
+/* Returns true, if ARG is convertible to TYPE using a NOP_EXPR.  */
 
 bool
 fold_convertible_p (const_tree type, const_tree arg)
 {
-  const_tree orig = TYPE_P (arg) ? arg : TREE_TYPE (arg);
+  const_tree orig = TREE_TYPE (arg);
 
   if (type == orig)
     return true;
@@ -2388,7 +2387,7 @@ fold_convertible_p (const_tree type, const_tree arg)
       return (VECTOR_TYPE_P (orig)
 	      && known_eq (TYPE_VECTOR_SUBPARTS (type),
 			   TYPE_VECTOR_SUBPARTS (orig))
-	      && fold_convertible_p (TREE_TYPE (type), TREE_TYPE (orig)));
+	      && tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (orig)));
 
     default:
       return false;
diff --git a/gcc/testsuite/gcc.dg/pr105250.c b/gcc/testsuite/gcc.dg/pr105250.c
new file mode 100644
index 00000000000..665dd95d8cb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr105250.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-w -Wno-psabi -O2" } */
+
+typedef int __attribute__((__vector_size__(4))) T;
+typedef int __attribute__((__vector_size__(8))) U;
+typedef int __attribute__((__vector_size__(16))) V;
+typedef int __attribute__((__vector_size__(32))) W;
+typedef _Float32 __attribute__((__vector_size__(16))) F;
+typedef _Float64 __attribute__((__vector_size__(32))) G;
+void foo();
+
+foo(int, int, int, int, U, U, V, V, W, W, int,
+     T, int, U, U, V, V, W, W, T,
+     T, int, U, U, V, V, W, W, T,
+     T, int, W, W, T, T, int, int, int,
+     int, int, int, W, int, int, int, int, int, int,
+     V, W, T, int, int, U, F, int, int, int,
+     int, int, int, G)
+{
+  foo(0, 0, 0, 0, (U){}, (U){}, (V){}, (V){}, (W){},
+       (W){}, 2, (T){}, 0, 0, 0, 0, (U){}, (U){},
+       (V){}, (V){}, (W){}, (W){}, (T){},
+       (T){}, 0, 0, 0, 0, (U){}, (U){}, (V){},
+       (V){}, (W){}, (W){}, (T){}, (T){}, 0, 0, 0,
+       0, 0, 0, (T){},
+       (T){}, (W){},
+       (W){}, (T){}, (T){}, 0, 0, 0, 0, 0, 0, (W){},
+       (V){}, (W){}, (T){}, 0, 0, (U){}, (F){});
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-19 14:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19 14:02 [gcc r11-10013] tree-optimization/105250 - adjust fold_convertible_p PR105140 fix Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).