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: 1773355 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=cdPyY5xS; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q5H004FCyz23v2 for ; Tue, 25 Apr 2023 19:34:39 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B465B385840F for ; Tue, 25 Apr 2023 09:34:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B465B385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682415276; bh=NHO7pKVSg3Mt1kgUPS5PjVcH2Ux7xmK3U8znBaLfD84=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=cdPyY5xSLm9acs6EX/fHei7aGtiDHRe3/jkhkMnvxXIQIDJftCm88gNaqY8GF3Q9o Msefn/R8lYh3YbkrrOCyCveMrsbySddpw1VTlaabxVL9QI07jAbkBXuJv7dXb2rfnU iw4XByOAN2glaB+Rwuv7CqNZ2ttX66E3+cbKRWMQ= 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-Google-Smtp-Source: AKy350Z2PiJp3eDf3U64zIzY150DqJg76HbCOV6tOu0lxYZZxjT/l8EOSqQE9HJCLIUUREarkSKoVw== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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. */