From patchwork Fri Dec 22 08:21:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 182591 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp918729dyi; Fri, 22 Dec 2023 00:26:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGnZA4q0vDrpXgE+qFJhKOPc5oXaTZ/aQvyxSFz33MaDrv49G173oA56PDC36BPAILV0TU7 X-Received: by 2002:a05:6214:528f:b0:67f:8282:69db with SMTP id kj15-20020a056214528f00b0067f828269dbmr770812qvb.35.1703233581756; Fri, 22 Dec 2023 00:26:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703233581; cv=pass; d=google.com; s=arc-20160816; b=AY2trH3tfcKEDMTunbvODQaFahTW1vC1UMM1+855HXrqSQp2TuSsoICYAgTsjRzLe3 d3oD7lLyhgJrypgRdJ3RPOtLRLJO9dW6dpdyPIy93354NncxKgmXfjoD1Z6JPkh4+OAs J0Iy080qtmR5Efs8rqC6ciYeUWQvJ+TjhblpYH6PXYvjMfEJMsvZ4NgkIM2450Q2MWJl P+sGpuWVAffQUspS1/qobkUK0T8dSlI6n3H01HuoB54OJ2U8yZsG0X/T4Lswn5Xvaz14 iN0SYMLgp3MvmtTnxdL2sbLGG91PUyhHAFVFrGFaTp1tI53F1t05KWgOgyILCvDheifV BjYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=ip0OSkJxyCiZQQjxhAniq47bXAbjCnwtyrLgFW+wBV0=; fh=0Wn18Pc4QKWYfmvMM5uwwFQaI8im56/Ex2wr72P6VV4=; b=auToD+5dQDc7BpW/RzWGckbTvHbIPkUijQsKoCoTkQM3gdHZHmNNo6XOgueOvCbTAT 4sVSBZlEeBzh1c++xhk/WD6tTv7AEVdV0vosqCLKy0+KAWYLXdZeoAlGjVcz0bVtY/ZS tQfQgfLFWuR1tohn2d7Kzj/Xv3pcKEC/LKs1hXBK09IJbX1Afs7Bc1WAZqphhnYrJIpf bsJiislyeH0aVH3e7mzJoH2f2KdzcErmyZ+SM92+xniS1B+XWe8GL9FFs/CyBzWlKoLd V+SKPBUQANKThExYjI5XpGE8BPZvogyl6rvIQIMwe8ERoaXybf2d96fygLW4MyF51uUV Dv9Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IzXsekCt; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id q11-20020a0ce20b000000b0067f911915easi1693943qvl.86.2023.12.22.00.26.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 00:26:21 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IzXsekCt; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A94B3858297 for ; Fri, 22 Dec 2023 08:26:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9A40F3858D3C for ; Fri, 22 Dec 2023 08:21:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A40F3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9A40F3858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703233418; cv=none; b=rwps+GBFatO8nFeldbnsAlYMXPvu3gNrkynQ9767dOynwVXDcX2/kCS5/58sbn3ZfQLXN/JrsZiNP1zflRVzNWmlB8o5cdVb8sWPRgfsyZg4Vtb+ctErScwfTzyVY38bTNeXN0jVK6BLJ3nJtn1kTuChll4iVJmwSyLgGhbvoFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703233418; c=relaxed/simple; bh=EWKVy78Qc+Kfn4ZmQo7HV4qsnxtxLU+/C1YbO9ttVoE=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=GUToayhumnMFbtGqiHuCZtPTPKDVlROnifU8X8/IwrWc4ei5TTqHDLs0VrPVM39OcUE7ghmJkp7FfTnweaV1D+plk31q+dz5kI8nbhgT7cVnylnV9jMKMSPNPUFIo5WDct0kVSC9RJ7pa2U1bp9/cQJiMSmQakvVOJRUyBGqMsw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703233296; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=ip0OSkJxyCiZQQjxhAniq47bXAbjCnwtyrLgFW+wBV0=; b=IzXsekCtZuxDaVp0pHhZryA9dM9KJHOnQoOSKLlIYEJq+0XaqP09sl2D638ey2JBFuJyNj h/IeAxrxt0yQLHrQvDwLommKF2NDt1a9paoUn9S4JLrjC38BFuzXGiGbgrvtIqvgj0F8mk 5QcDG2dr7NdqI8K9LvGE2+fvNCRrTfs= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-g241T53mPdmUaxz1GrFJ0g-1; Fri, 22 Dec 2023 03:21:34 -0500 X-MC-Unique: g241T53mPdmUaxz1GrFJ0g-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 211971C068C0; Fri, 22 Dec 2023 08:21:34 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D46ABC15968; Fri, 22 Dec 2023 08:21:33 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3BM8LV1i241261 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 22 Dec 2023 09:21:31 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3BM8LULK241260; Fri, 22 Dec 2023 09:21:30 +0100 Date: Fri, 22 Dec 2023 09:21:30 +0100 From: Jakub Jelinek To: Richard Biener , Jan Hubicka Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] symtab-thunks: Use aggregate_value_p even on is_gimple_reg_type returns [PR112941] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785969856104782365 X-GMAIL-MSGID: 1785969856104782365 Hi! Large/huge _BitInt types are returned in memory and the bitint lowering pass right now relies on that. The gimplification etc. use aggregate_value_p to see if it should be returned in memory or not and use = _123; return ; rather than return _123; But expand_thunk used e.g. by IPA-ICF was performing an optimization, assuming is_gimple_reg_type is always passed in registers and not calling aggregate_value_p in that case. The following patch changes it to match what the gimplification etc. are doing. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-12-22 Jakub Jelinek PR tree-optimization/112941 * symtab-thunks.cc (expand_thunk): Check aggregate_value_p regardless of whether is_gimple_reg_type (restype) or not. * gcc.dg/bitint-60.c: New test. Jakub --- gcc/symtab-thunks.cc.jj 2023-08-24 15:37:28.698418172 +0200 +++ gcc/symtab-thunks.cc 2023-12-21 16:42:41.406127267 +0100 @@ -479,21 +479,15 @@ expand_thunk (cgraph_node *node, bool ou resdecl, build_int_cst (TREE_TYPE (resdecl), 0)); } - else if (!is_gimple_reg_type (restype)) + else if (aggregate_value_p (resdecl, TREE_TYPE (thunk_fndecl))) { - if (aggregate_value_p (resdecl, TREE_TYPE (thunk_fndecl))) - { - restmp = resdecl; + restmp = resdecl; - if (VAR_P (restmp)) - { - add_local_decl (cfun, restmp); - BLOCK_VARS (DECL_INITIAL (current_function_decl)) - = restmp; - } + if (VAR_P (restmp)) + { + add_local_decl (cfun, restmp); + BLOCK_VARS (DECL_INITIAL (current_function_decl)) = restmp; } - else - restmp = create_tmp_var (restype, "retval"); } else restmp = create_tmp_reg (restype, "retval"); --- gcc/testsuite/gcc.dg/bitint-60.c.jj 2023-12-21 16:49:41.289298560 +0100 +++ gcc/testsuite/gcc.dg/bitint-60.c 2023-12-21 16:49:09.061746003 +0100 @@ -0,0 +1,20 @@ +/* PR tree-optimization/112941 */ +/* { dg-do compile { target bitint575 } } */ +/* { dg-options "-O2 -std=c23" } */ + +unsigned _BitInt(495) f1 (signed _BitInt(381) x) { unsigned _BitInt(539) y = x; return y; } +unsigned _BitInt(495) f2 (unsigned _BitInt(381) x) { unsigned _BitInt(539) y = x; return y; } +unsigned _BitInt(495) f3 (signed _BitInt(381) x) { _BitInt(539) y = x; return y; } +unsigned _BitInt(495) f4 (unsigned _BitInt(381) x) { _BitInt(539) y = x; return y; } +_BitInt(495) f5 (signed _BitInt(381) x) { unsigned _BitInt(539) y = x; return y; } +_BitInt(495) f6 (unsigned _BitInt(381) x) { unsigned _BitInt(539) y = x; return y; } +_BitInt(495) f7 (signed _BitInt(381) x) { _BitInt(539) y = x; return y; } +_BitInt(495) f8 (unsigned _BitInt(381) x) { _BitInt(539) y = x; return y; } +unsigned _BitInt(495) f9 (signed _BitInt(381) x) { return (unsigned _BitInt(539)) x; } +unsigned _BitInt(495) f10 (unsigned _BitInt(381) x) { return (unsigned _BitInt(539)) x; } +unsigned _BitInt(495) f11 (signed _BitInt(381) x) { return (_BitInt(539)) x; } +unsigned _BitInt(495) f12 (unsigned _BitInt(381) x) { return (_BitInt(539)) x; } +_BitInt(495) f13 (signed _BitInt(381) x) { return (unsigned _BitInt(539)) x; } +_BitInt(495) f14 (unsigned _BitInt(381) x) { return (unsigned _BitInt(539)) x; } +_BitInt(495) f15 (signed _BitInt(381) x) { return (_BitInt(539)) x; } +_BitInt(495) f16 (unsigned _BitInt(381) x) { return (_BitInt(539)) x; }