From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2049) id AB1D83857C63; Fri, 1 Oct 2021 09:16:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB1D83857C63 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Matthew Malcomson To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] c: Add missing fold in build_binary_op X-Act-Checkin: gcc X-Git-Author: Alex Coplan X-Git-Refname: refs/vendors/ARM/heads/morello X-Git-Oldrev: a58177380c9bac44269e64ac78f0474d23834e5f X-Git-Newrev: 56b253703f286253cadc701e01984090766e3c15 Message-Id: <20211001091643.AB1D83857C63@sourceware.org> Date: Fri, 1 Oct 2021 09:16:43 +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, 01 Oct 2021 09:16:43 -0000 https://gcc.gnu.org/g:56b253703f286253cadc701e01984090766e3c15 commit 56b253703f286253cadc701e01984090766e3c15 Author: Alex Coplan Date: Wed Sep 22 11:20:47 2021 +0100 c: Add missing fold in build_binary_op In build_binary_op we call c_fully_fold on the address value operand before building a replace_address_value node, since c_fully_fold (which would otherwise be called later) can't fold inside replace_address_value nodes. However, this didn't account for possible c_maybe_const_expr nodes in the intcap expression itself. This adds a call to c_fully_fold for the intcap operand. gcc/c/ChangeLog: * c-typeck.c (build_binary_op): Also call c_fully_fold on the intcap operand before building a replace_address_value node. gcc/testsuite/ChangeLog: * gcc.target/aarch64/morello/intcap-fold-ice.c: New test. Diff: --- gcc/c/c-typeck.c | 3 ++- gcc/testsuite/gcc.target/aarch64/morello/intcap-fold-ice.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 5b6c6e186af..30a082b3144 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -12962,8 +12962,9 @@ build_binary_op (location_t location, enum tree_code code, intcap = convert (ic_type, intcap); /* We can't fold inside REPLACE_ADDRESS_VALUE calls, so ensure - we've folded the address value expression. */ + we've folded the operands. */ ret = c_fully_fold (ret, false, NULL); + intcap = c_fully_fold (intcap, false, NULL); ret = fold_build_replace_address_value_loc (location, intcap, ret); } diff --git a/gcc/testsuite/gcc.target/aarch64/morello/intcap-fold-ice.c b/gcc/testsuite/gcc.target/aarch64/morello/intcap-fold-ice.c new file mode 100644 index 00000000000..95b73f8f7bb --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/morello/intcap-fold-ice.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +/* This was ICEing due to a missing fold when building + replace_address_value nodes in the C frontend. */ + +struct { + __uintcap_t a; +} * b; +void c() { long a = (b ? b->a : 0) + a; }