From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 98AF63857712; Fri, 28 Apr 2023 09:49:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 98AF63857712 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682675354; bh=5kcYmqv8EqoA6u8mcfsSmNhru0AndMPvZqGvWHqAEVI=; h=From:To:Subject:Date:From; b=vuVZXrbWZ7uydJwveLwKFlVf72OdRPgWAT11ATIpSMAoVfrB/rOpAabLwe+tc/gKa 7ogVCCj2j638wr4ZGqIi6dwf6WcW6ZpGZTWBzPPAzv42VHCI0USYxkhHBynDXf8RNs L25jc4fSIxeybL4vBg/37hsfZy4D8G+384qmziQM= 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 r14-323] Avoid more invalid GIMPLE with register bases X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 821ef93976e750c118d42a2ad33b96dbd1b9f3a5 X-Git-Newrev: 977a43f5ba778b5c5cf9c56ba04ed4fde5d1ae78 Message-Id: <20230428094914.98AF63857712@sourceware.org> Date: Fri, 28 Apr 2023 09:49:14 +0000 (GMT) List-Id: https://gcc.gnu.org/g:977a43f5ba778b5c5cf9c56ba04ed4fde5d1ae78 commit r14-323-g977a43f5ba778b5c5cf9c56ba04ed4fde5d1ae78 Author: Richard Biener Date: Fri Apr 28 09:25:16 2023 +0200 Avoid more invalid GIMPLE with register bases The Ada frontend, for example with gnat.dg/inline2_pkg.adb, tends to create VIEW_CONVERT expressions with aggregate type even of non-aggregate entities. In this case for example return = (BIT_FIELD_REF (number), 16, 16> & 32640) != 32640; currently gimplification and SSA rewrite turn this into _1 = BIT_FIELD_REF (number_2(D)); which is two operations on a register. While as seen with PR109652 we might not want to completely rule out register to aggregate type VIEW_CONVERTs we definitely do not want to stack multiple ops here. The solution is to make sure the gimplifier puts a non-register as the base object. For the above this will add number.1 = number; and use number.1 in the compound reference. Code generation is unchanged, FRE optimizes this to BIT_FIELD_REF . I think BIT_FIELD_REF could be always rewritten into BIT_FIELD_REF , but that's a separate thing. * gimplify.cc (gimplify_compound_lval): When there's a non-register type produced by one of the handled component operations make sure we get a non-register base. Diff: --- gcc/gimplify.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index c38a962dd04..3740a8979af 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -3264,6 +3264,11 @@ gimplify_compound_lval (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, } need_non_reg = true; } + else if (!is_gimple_reg_type (TREE_TYPE (t))) + /* When the result of an operation, in particular a VIEW_CONVERT_EXPR + is a non-register type then require the base object to be a + non-register as well. */ + need_non_reg = true; } /* Step 2 is to gimplify the base expression. Make sure lvalue is set