From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 1DD02395B422; Fri, 27 May 2022 13:15:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DD02395B422 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-10768] middle-end/105140 - fix bogus recursion in fold_convertible_p X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: bdfe7e5510b28c3ab8f8cd0fd7f715f2da3af938 X-Git-Newrev: c515adf5d339ad942207d9121cf49e5b6c84093e Message-Id: <20220527131538.1DD02395B422@sourceware.org> Date: Fri, 27 May 2022 13:15:38 +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:38 -0000 https://gcc.gnu.org/g:c515adf5d339ad942207d9121cf49e5b6c84093e commit r10-10768-gc515adf5d339ad942207d9121cf49e5b6c84093e Author: Richard Biener Date: Mon Apr 4 10:20:05 2022 +0200 middle-end/105140 - fix bogus recursion in fold_convertible_p fold_convertible_p expects an operand and a type to convert to but recurses with two vector component types. Fixed by allowing types instead of an operand as well. 2022-04-04 Richard Biener PR middle-end/105140 * fold-const.c (fold_convertible_p): Allow a TYPE_P arg. * gcc.dg/pr105140.c: New testcase. (cherry picked from commit eaaf77dd85c333b116111bb1ae6c080154a4e411) Diff: --- gcc/fold-const.c | 5 +++-- gcc/testsuite/gcc.dg/pr105140.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 94f92e63893..665ed82b590 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2356,12 +2356,13 @@ build_zero_vector (tree type) return build_vector_from_val (type, t); } -/* Returns true, if ARG is convertible to TYPE using a NOP_EXPR. */ +/* Returns true, if ARG, an operand or a type, is convertible to TYPE + using a NOP_EXPR. */ bool fold_convertible_p (const_tree type, const_tree arg) { - tree orig = TREE_TYPE (arg); + const_tree orig = TYPE_P (arg) ? arg : TREE_TYPE (arg); if (type == orig) return true; diff --git a/gcc/testsuite/gcc.dg/pr105140.c b/gcc/testsuite/gcc.dg/pr105140.c new file mode 100644 index 00000000000..14bff2f7f9c --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr105140.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-Os -w -Wno-psabi" } */ + +typedef char __attribute__((__vector_size__ (16 * sizeof (char)))) U; +typedef int __attribute__((__vector_size__ (16 * sizeof (int)))) V; + +void bar (); + +bar (int i, int j, int k, V v) +{ +} + +void +foo (void) +{ + bar ((V){}, (V){}, (V){}, (U){}); +}