From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id D47DC3858D37 for ; Fri, 28 Apr 2023 09:48:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D47DC3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D593F2003B for ; Fri, 28 Apr 2023 09:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1682675281; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=N/cMeAFH0cE+zc/bk0y4yjrkMoXNodN5EsblcC2lcyM=; b=Ot5UfiZADB6SbikT9S7CInUVDVkHv4TA+MEptUugd16jpUMn5dnGIr1ALTnDGsiGrHBr8V E2/20K9729fFqUAPqe4EDCKROcwjgp/5nM4RH2vbMkcCG0lde/dxkUPpkwqfwHBdjCZIu4 glIVboddJBzjr32LZNUYGFc90amTnz0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1682675281; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=N/cMeAFH0cE+zc/bk0y4yjrkMoXNodN5EsblcC2lcyM=; b=hzFtJLbrkjNNI3MoJiSZJ+an9Hm4F2U645PGci7bAUPruu1j23vZ+J4VNP6TouG+5f3ktS UXEePnwHA4IgdfBw== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id CB87B2C153 for ; Fri, 28 Apr 2023 09:48:01 +0000 (UTC) Date: Fri, 28 Apr 2023 09:48:01 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid more invalid GIMPLE with register bases User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,MISSING_MID,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20230428094801.-9M393A-UKtY2sP48CW9oaENltg5QuCvAJuDB3s0NEU@z> 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. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. * 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. --- 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 -- 2.35.3