From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-2f58125b957so4957395f8f.3 for ; Tue, 25 Apr 2023 02:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1682415255; x=1685007255; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=NHO7pKVSg3Mt1kgUPS5PjVcH2Ux7xmK3U8znBaLfD84=; b=AYJ/3In5ymxy98R0arX/4J6oog4oPLlzm4P1Mt4cdcunYPlsbrZ155Jl6pNDsaNg+0 AGvA9JlOPudkh+AFeMD5OV2o3afdOqgd4iwqCTx5jx2bHub/mIqAKZfOxaTTspLh6dTs XDsMUhSOC7gIXVQUV1WRlEV+tg9oqBpxaT1Fl+f8iSiux6k/rdvDFi6hjwml7h+UxCYI 2N5Hx7LVG5gjCLnPtpUciguiPJlJCPhIqT0DwHlOjpv7d+6PEfcuiWFixyFKZQRewVOl HuF56qmhWcaeqw0+3swT29N42pI0zB+MY9GzQwJhoVnPuaYsLHt5FDfUr87s70lCl4fP hMrA== 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) From: Eric Botcazou 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 Content-Type: multipart/mixed; boundary="nextPart9096856.CDJkKcVGEf" Content-Transfer-Encoding: 7Bit 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 List-Id: This is a multi-part message in MIME format. --nextPart9096856.CDJkKcVGEf Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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. -- Eric Botcazou --nextPart9096856.CDJkKcVGEf Content-Disposition: attachment; filename="p.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="p.diff" 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. */ --nextPart9096856.CDJkKcVGEf--