From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id B84A7396E86B; Fri, 27 May 2022 13:15:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B84A7396E86B MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10771] tree-optimization/105250 - adjust fold_convertible_p PR105140 fix X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 1cccf2e43b43d6e75df2257ddc2682dceb9f04ae X-Git-Newrev: 644185d0e42fd93d1f793475a0117d6751fb042e Message-Id: <20220527131553.B84A7396E86B@sourceware.org> Date: Fri, 27 May 2022 13:15:53 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 May 2022 13:15:53 -0000 https://gcc.gnu.org/g:644185d0e42fd93d1f793475a0117d6751fb042e commit r10-10771-g644185d0e42fd93d1f793475a0117d6751fb042e Author: Richard Biener 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 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 665ed82b590..2dccd10748a 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2356,13 +2356,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; @@ -2394,7 +2393,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..9225e006a58 --- /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 p1, int p2, int p3, int p4, U p5, U p6, V p7, V p8, W p9, W p10, int p11, + T p12, int p13, U p14, U p15, V p16, V p17, W p18, W p19, T p20, + T p21, int p22, U p23, U p24, V p25, V p26, W p27, W p28, T p29, + T p30, int p31, W p32, W p33, T p34, T p35, int p36, int p37, int p38, + int p39, int p40, int p41, W p42, int p43, int p44, int p45, int p46, int p47, int p48, + V p49, W p50, T p51, int p52, int p53, U p54, F p55, int p56, int p57, int p58, + int p59, int p60, int p61, G p62) +{ + 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){}); +}