From patchwork Tue Apr 25 09:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 87326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3280489vqo; Tue, 25 Apr 2023 02:35:03 -0700 (PDT) X-Google-Smtp-Source: AKy350aR0u9PmkJDXQZUb2YDQkYyGfJAhdOPhOB6waXoXHsku56G4vbzjn30F0nbTdiNjS90I0U5 X-Received: by 2002:aa7:da0f:0:b0:508:14f2:399c with SMTP id r15-20020aa7da0f000000b0050814f2399cmr15441775eds.10.1682415303024; Tue, 25 Apr 2023 02:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682415303; cv=none; d=google.com; s=arc-20160816; b=Vx04+zdVklXBtvwkUB4ALYrji63eYM2Q/Qyn2rpi9UR7D6FAdQyMAf2z/CLeRHS/Fp +xYPfXDRxYb9l/YYhvXTW5hpTc/jxn8Gq1lzNytjjyDDHY4jYmj3jlt46qjJAOsaOVwb SErbNh9YnQFbvcR0kDUZUFxyRXQbaeov8br2EFv26xTE8LcGbh2Tzz0jRlE+Bd7HC/P2 +SL0tK0tpMmrxJ7fVrO/lQhpeCMB3p+06/zHA3gZgaoMVDKteadw3TIaiE0JAacUuQDR OMtYQ1fcnYE8wYvfFW34Y+DuC1k72rKFmLc+JBhQdhpftbxrEbIYcAORcG+KfB8AWjBX 6xXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=NHO7pKVSg3Mt1kgUPS5PjVcH2Ux7xmK3U8znBaLfD84=; b=S3sOrZUiGQyGD5zC89FzMfJExikLUhbaZwzElT9wgewDD+NT/rzSLTpvlneau3dgcY vxRjRuAZIYq4VtN5c2KXxE84BNHRR1jjiIf5aQfZGklJYO/0qz3+ybdE8sLiDWTaZJI3 7I/89TswjgUv/khVTYORo65Rz00zpTKBKuOKn9U0Ki78Bx//cIHSIL7usDltdqk5j/0z 9hN8FytSSSzA7d2dgNX7OsXur5aE8NWafsqAeofn0euZr8qD/ULo36KbpRnYmWq0LOwg 598GNTmZ8NorN/6jMBM1pX1kF4F7Z79I4gh3jVKYn13ArW4Spa48pXKWUioSN1cL1lov cRYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kikRmmGa; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b2-20020aa7c902000000b004ad7a9f7929si10399831edt.136.2023.04.25.02.35.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Apr 2023 02:35:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kikRmmGa; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E8E3C3858C5E for ; Tue, 25 Apr 2023 09:35:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8E3C3858C5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682415301; bh=NHO7pKVSg3Mt1kgUPS5PjVcH2Ux7xmK3U8znBaLfD84=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kikRmmGaeZDRW1ZxTI0CaUbYXrYPoQtKKMOXigq+VANofNeD51QGmdskOxzanaggl 1UbYAwjEVk/C84sUO3v+91rypKV1V1pUCt55e3A6IYTt+PKPx99HVBOwGrdC9LryDp cwHYYM/mB9rEv5VJixkN1aSeZTQWW3K2szp3iiQM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 294203858D32 for ; Tue, 25 Apr 2023 09:34:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 294203858D32 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-2f58125b957so4957395f8f.3 for ; Tue, 25 Apr 2023 02:34:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682415255; x=1685007255; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NHO7pKVSg3Mt1kgUPS5PjVcH2Ux7xmK3U8znBaLfD84=; b=Mcpw50Tlby2geFDBDgI/i59nVP20koikr850mAeMBnu017QEP8rcPiFyNVFPAVFZ1K KnlD6eGSbey9DuiEoU50Ik8L6oRFt8uB68GQmH+lugd30r0kveKEGpFm7UinHpml4pfv GWZtpm8H46gxDA7INkYnBWJuAUVSf1pGP4kEbvfUi9ROFEUy3NrWX5begtQwvVhNgM3h fGy2fb6d3A6E5xJcmYNOdzycHB4vSmXBNS6MBTlLjPxwT1k++FKviIg+wptmQNHix3L9 2i3YWjO268HF33VRMiMImdRz8uaBNyIr2a34jvK+40YaZ5vj103TL24DxYV1V9bjaul6 rOfQ== X-Gm-Message-State: AAQBX9fpEyziMic9LS1Z0B3O8/AQG6+YbqCx5U5DchRlskvZAfm7xPlF 50TSphDlFtZptgJxgC89gngoxWJq9KxmMRKtpP14bg== X-Received: by 2002:adf:db4e:0:b0:2f2:3dbf:6922 with SMTP id f14-20020adfdb4e000000b002f23dbf6922mr10262545wrj.22.1682415254889; Tue, 25 Apr 2023 02:34:14 -0700 (PDT) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id i6-20020a5d6306000000b002fed865c55esm12667353wru.56.2023.04.25.02.34.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Apr 2023 02:34:14 -0700 (PDT) X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid creating useless debug temporaries Date: Tue, 25 Apr 2023 11:33:23 +0200 Message-ID: <3493207.iIbC2pHGDl@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Eric Botcazou via Gcc-patches From: Eric Botcazou Reply-To: Eric Botcazou Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764140308402023726?= X-GMAIL-MSGID: =?utf-8?q?1764140308402023726?= Hi, insert_debug_temp_for_var_def has some strange code whereby it creates debug temporaries for SINGLE_RHS (RHS for gimple_assign_single_p) but not for other RHS in the same situation. Removing it saves 25% of compilation time at -g -O for a pathological testcase I have. Bootstrapped/regtested on x86-64/Linux, OK for the mainline? 2023-04-25 Eric Botcazou * tree-ssa.cc (insert_debug_temp_for_var_def): Do not create superfluous debug temporaries for single GIMPLE assignments. diff --git a/gcc/tree-ssa.cc b/gcc/tree-ssa.cc index a5cad2d344e..4ca1f5f3104 100644 --- a/gcc/tree-ssa.cc +++ b/gcc/tree-ssa.cc @@ -412,8 +412,7 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var) { /* If there's a single use of VAR, and VAR is the entire debug expression (usecount would have been incremented again - otherwise), and the definition involves only constants and - SSA names, then we can propagate VALUE into this single use, + otherwise), then we can propagate VALUE into this single use, avoiding the temp. We can also avoid using a temp if VALUE can be shared and @@ -424,11 +423,9 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var) are deferred to a debug temp, although we could avoid temps at the expense of duplication of expressions. */ - if (CONSTANT_CLASS_P (value) + if (usecount == 1 || gimple_code (def_stmt) == GIMPLE_PHI - || (usecount == 1 - && (!gimple_assign_single_p (def_stmt) - || is_gimple_min_invariant (value))) + || CONSTANT_CLASS_P (value) || is_gimple_reg (value)) ; else @@ -466,11 +463,6 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var) if (value) { FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter) - /* unshare_expr is not needed here. vexpr is either a - SINGLE_RHS, that can be safely shared, some other RHS - that was unshared when we found it had a single debug - use, or a DEBUG_EXPR_DECL, that can be safely - shared. */ SET_USE (use_p, unshare_expr (value)); /* If we didn't replace uses with a debug decl fold the resulting expression. Otherwise we end up with invalid IL. */