From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2052.outbound.protection.outlook.com [40.107.13.52]) by sourceware.org (Postfix) with ESMTPS id 9F98A3858433 for ; Thu, 6 Apr 2023 10:57:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F98A3858433 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LemrycYX+icjslXb5PmjIrsVi0+FavDHvlV4hbDq41Y=; b=KIeDjs5lAWM62s9qC7MOqjRFxm5LXV0t3A/LgJFXxxuaF2NkM67Owize4TPow3YmP2akL7ojTZwMuXESDEvJUMBCiXzOlNAWxSTTDct6IlALJnGhgwcrk7lQhJsm/42AJbxPKTV9ffLpe7EuY/2jKAHE6zRU1ttOpZavsuCgikI= Received: from DB6PR0201CA0007.eurprd02.prod.outlook.com (2603:10a6:4:3f::17) by AM8PR08MB5636.eurprd08.prod.outlook.com (2603:10a6:20b:1c6::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.31; Thu, 6 Apr 2023 10:57:03 +0000 Received: from DBAEUR03FT055.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:3f:cafe::95) by DB6PR0201CA0007.outlook.office365.com (2603:10a6:4:3f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.43 via Frontend Transport; Thu, 6 Apr 2023 10:57:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT055.mail.protection.outlook.com (100.127.142.171) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.30 via Frontend Transport; Thu, 6 Apr 2023 10:57:03 +0000 Received: ("Tessian outbound 8b05220b4215:v136"); Thu, 06 Apr 2023 10:57:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2e6e37158e007b90 X-CR-MTA-TID: 64aa7808 Received: from 9e32bf65313d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3EF4CABA-99C2-4869-AEFD-0C8753FC2248.1; Thu, 06 Apr 2023 10:56:57 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9e32bf65313d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 06 Apr 2023 10:56:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mSzm7tpqVj9gXJnT3PahjEODrAaD5lyRDwKf0GgmW4+wDs0OcgEI1y30Nmv1rf9NXMtPUNKEeYn6cwR5bOJJDG9kVbPy9qJSZO/+rrFBg2M+YLyFxSnh0QUwFRfrhqIYKjRsC3blBOMvAVTVPEeFWeIBxg40JKIfgYWvAr68LfwB5b15QREJxHEXbdgaShi2qIRrq/dut9Gg/rBX6u3nrvsjIDyMKH8iEvwzUFDDnw3MF3bEurF8CmyF0Gg24JJlJStA1mHSuLfHFLNPOoqjnHd77Jfx/vZKNzqP5rJTlVkDBiJ2U1mjsoPZv/N/JvX1w1jBWNI+MYE3rvVcX07bjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LemrycYX+icjslXb5PmjIrsVi0+FavDHvlV4hbDq41Y=; b=hhe/3Dah5lCV7SNkr7wXEa1QUSsnfSP8/L17bJxayLV3EkjWaasDG9ARXaJ3V4v2tAi+y8Fd1tChfR9MlDQuU1q8TlGGBFU+XxPMo32w915anUnnh6QUsbfUZg+yeSmc249+KstY5ubmKLUX4FAbC3UM2HSvxJHkBAX8sO5BbUTFMI46Jk7s/kzoJNY1ttcV9IVWavE0dtlwu1OhmbloVEXzPY/OvceTfj8+1e+ntu5Wi0JoyBg3kpXPOpzVVONOENYakSNcLGcWTTKJOPQnS/LdLPCOmVBzYu9L5WT5LtKID5r50d5Jt0BDvsdK1dBodWk5I8ojP3yK0IxYnMtlFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LemrycYX+icjslXb5PmjIrsVi0+FavDHvlV4hbDq41Y=; b=KIeDjs5lAWM62s9qC7MOqjRFxm5LXV0t3A/LgJFXxxuaF2NkM67Owize4TPow3YmP2akL7ojTZwMuXESDEvJUMBCiXzOlNAWxSTTDct6IlALJnGhgwcrk7lQhJsm/42AJbxPKTV9ffLpe7EuY/2jKAHE6zRU1ttOpZavsuCgikI= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) by AM9PR08MB5876.eurprd08.prod.outlook.com (2603:10a6:20b:2d5::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.29; Thu, 6 Apr 2023 10:56:55 +0000 Received: from VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::73a3:ecc1:2c9c:3f71]) by VI1PR08MB5325.eurprd08.prod.outlook.com ([fe80::73a3:ecc1:2c9c:3f71%4]) with mapi id 15.20.6254.035; Thu, 6 Apr 2023 10:56:55 +0000 Date: Thu, 6 Apr 2023 11:56:47 +0100 From: Tamar Christina To: gcc-patches@gcc.gnu.org Cc: nd@arm.com, rguenther@suse.de, jlaw@ventanamicro.com, mliska@suse.cz Subject: [PATCH 2/3] RFC - match.pd: simplify debug dump checks Message-ID: Content-Type: multipart/mixed; boundary="m9203EutozRHsPpK" Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To VI1PR08MB5325.eurprd08.prod.outlook.com (2603:10a6:803:13e::17) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB5325:EE_|AM9PR08MB5876:EE_|DBAEUR03FT055:EE_|AM8PR08MB5636:EE_ X-MS-Office365-Filtering-Correlation-Id: 43fbbcc5-4512-44b3-f1af-08db368da7d0 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: d++6OgrKKdX6N45jU6v8riGNxl956Lb0tw2yiiKlwopmMXgcy61+JJPy7O/ptVedoZ9h4jCpl60q82TzYJLwYEJPPC85pdJW3hHn4ruiDMH2Bv4XbhpISu33lDzEz4+3Gd3oJxNplq0feeLMW5WxUEaGvOPK7Vu3M4gLIV9TcMjsDltHXQvK3ESE87GZdCkDC3mDwVuzR0tvVebQPCjAtsh/b/9ivsSc2KvYYl5cq4MiRPNLYr9d17t/A9WhzE5YpuJzrxymiYILSuEN8o5SHrlDdWgfenEVySbdT6msROxSruEk63E+EAgS/a4Udy04sWI9s5WpWtXlw6KzqMr1oBKkVgrXX5RCcbFJEBjdKNjIgczm3RrSVDLJa/paC+3IkDqLFyV5I5A1rC0+aCYPS5n0HQnwoBlyBpQodzgnhvsxVfgs+3Es0hQ4SH4JJil0PgXjDWU484pe3v+QrK95vTA0Wne8FB+uWqKEXZ3jIUKulGo8GRb2T3vDDh1VmMknbA7L0Ot/EytMPCaa/cH9GZWXyxxDN5ZDEB11SXapKUraPWr3oLGln8Z2tzZpQpXqxA9Eblk64tC/63LkiaZxpRsYu2SJ3U8oEZHPSW59d3TMQPPg35PDMtTmrE2i/SfG X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB5325.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(39860400002)(346002)(396003)(376002)(136003)(451199021)(38100700002)(4326008)(235185007)(8676002)(8936002)(6916009)(5660300002)(66476007)(66946007)(66556008)(41300700001)(86362001)(36756003)(44832011)(6486002)(2906002)(478600001)(316002)(2616005)(6512007)(44144004)(33964004)(4743002)(186003)(26005)(6506007)(6666004)(2700100001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB5876 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 5946cb8e-c491-4a1d-8eec-08db368da277 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W7DftSIKB2mEBINhcuPNBDfe6sDghP+3X4aQBw0x9lX/3Y+m6cMfAEme9Ay7ij6WTANmqUeDgUVcBJgn7WWxlXw7Z1y/Sv/jW/lSyQi1gDxTLxXUnFdJyglC79181e3m0+hJYmoQHUvK6ATkRG/FNfc2dIolGLt/1Fhh3TKuaxELZfljrw4MiqEI6K3llsPFfFhfsLxyncW1Gv8BPKYqG6ZSeKeCwkaHq7s1RWjzTQ4LmTqifHV9wbZPlcsJIZ7016alHi9nnynYVP2D7WrlpEb9OPVCKIYV5ikhDlRwtR2yqFE8XVQDQF6w3/fskRssVpsr+pWMdXziOdEJolIXJ1fwUpGGLaqqH1z9KrIPXkaq8aMH2tyCmKWJrBm4CY78/6f2M17SkwNA8CkB9dStCEazR8idvVxW/9eEyoaGvyziODtn+ANwGRlyGRv/Eb26/muKm3WODYBiD++Hj5ayCQyHiQ9lI5k5Si8Dd/jXqyGsefAOieHSbzbyrs3dLk6wDbt1kFwdktz3STvlMsv0n9oSv0N9fc9QuqQTa3BBdtO6IWt+mlAiQNzZGPkAAXOoAeCPqnA5hja/AxqMwcT8OGWKMjZrj3r3QajuX1U2kSoY0ea0emy8Dn5zd6+bHG7ZWYPGemlQJe50Rn9sp+Xwwlz7OSop1Ctb7E+dquoxVtYuO9RwBZPtwWaR3wRqAaU/Bdl/BHfntIL3MNNDbkzNPH5UYNW4cMnRZ0u72d4QtqA= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(396003)(39860400002)(346002)(136003)(451199021)(46966006)(36840700001)(40470700004)(356005)(81166007)(2616005)(41300700001)(44144004)(33964004)(6512007)(107886003)(6666004)(26005)(6506007)(6486002)(40480700001)(86362001)(478600001)(36756003)(316002)(4743002)(186003)(40460700003)(70206006)(70586007)(4326008)(8676002)(6916009)(5660300002)(44832011)(47076005)(235185007)(8936002)(2906002)(36860700001)(82740400003)(82310400005)(336012)(2700100001);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Apr 2023 10:57:03.6677 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43fbbcc5-4512-44b3-f1af-08db368da7d0 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT055.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5636 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,KAM_LOTSOFHASH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY 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: --m9203EutozRHsPpK Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Hi All, Just sending these so people can test the series This is a small improvement in QoL codegen for match.pd to save time not re-evaluating the condition for printing debug information in every function. There is a small but consistent runtime and compile time win here. The runtime win comes from not having to do the condition over again, and on Arm plaforms we now use the new test-and-branch support for booleans to only have a single instruction here. Compile time win is gotten from not having to do all the string parsing for the printf and having less string interning to do. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Ok for GCC 14? Thanks, Tamar gcc/ChangeLog: PR bootstrap/84402 * dumpfile.h (dump_folding_p): New. * dumpfile.cc (set_dump_file): Use it. * generic-match-head.cc (dump_debug): New. * gimple-match-head.cc (dump_debug): New. * genmatch.cc (output_line_directive): Support outputting only line because file is implied. (dt_simplify::gen_1): Call debug_dump instead of printf. --- inline copy of patch -- diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h index 7d5eca899dcc98676a9ce7a7efff8e439854ff89..e7b595ddecdcca9983d9584b8b2417ae1941c7d4 100644 --- a/gcc/dumpfile.h +++ b/gcc/dumpfile.h @@ -522,6 +522,7 @@ parse_dump_option (const char *, const char **); extern FILE *dump_file; extern dump_flags_t dump_flags; extern const char *dump_file_name; +extern bool dump_folding_p; extern bool dumps_are_enabled; diff --git a/gcc/dumpfile.cc b/gcc/dumpfile.cc index 51f68c8c6b40051ba3125c84298ee44ca52f5d17..f805aa73f3aa244d847149eec26505181ce4efe8 100644 --- a/gcc/dumpfile.cc +++ b/gcc/dumpfile.cc @@ -63,6 +63,7 @@ FILE *dump_file = NULL; const char *dump_file_name; dump_flags_t dump_flags; bool dumps_are_enabled = false; +bool dump_folding_p = false; /* Set global "dump_file" to NEW_DUMP_FILE, refreshing the "dumps_are_enabled" @@ -73,6 +74,7 @@ set_dump_file (FILE *new_dump_file) { dumpfile_ensure_any_optinfo_are_flushed (); dump_file = new_dump_file; + dump_folding_p = dump_file && (dump_flags & TDF_FOLDING); dump_context::get ().refresh_dumps_are_enabled (); } diff --git a/gcc/generic-match-head.cc b/gcc/generic-match-head.cc index f011204c5be450663231bdece0596317b37f9f9b..16b8f9f3b61d3d5651a5a41a8c0552f50b55cc7c 100644 --- a/gcc/generic-match-head.cc +++ b/gcc/generic-match-head.cc @@ -102,3 +102,17 @@ optimize_successive_divisions_p (tree, tree) { return false; } + +/* Helper method for debug printing to reducing string parsing overhead. Keep + in sync with version in gimple-match-head.cc. */ + +static +void dump_debug (bool simplify, int loc, const char *file, int lineno) +{ + if (simplify) + fprintf (dump_file, "Applying pattern %s:%d, %s:%d\n", "match.pd", loc, + file, lineno); + else + fprintf (dump_file, "Matching expression %s:%d, %s:%d\n", "match.pd", loc, + file, lineno); +} \ No newline at end of file diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc index 638606b2502f640e59527fc5a0b23fa3bedd0cee..bd7c6ff4a3fb89d456b02242707fd823b737f20d 100644 --- a/gcc/genmatch.cc +++ b/gcc/genmatch.cc @@ -185,7 +185,8 @@ fprintf_indent (FILE *f, unsigned int indent, const char *format, ...) static void output_line_directive (FILE *f, location_t location, - bool dumpfile = false, bool fnargs = false) + bool dumpfile = false, bool fnargs = false, + bool loc_only = false) { const line_map_ordinary *map; linemap_resolve_location (line_table, location, LRK_SPELLING_LOCATION, &map); @@ -204,7 +205,9 @@ output_line_directive (FILE *f, location_t location, else ++file; - if (fnargs) + if (loc_only) + fprintf (f, "%d", loc.line); + else if (fnargs) fprintf (f, "\"%s\", %d", file, loc.line); else fprintf (f, "%s:%d", file, loc.line); @@ -3431,14 +3434,11 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result) needs_label = true; } - fprintf_indent (f, indent, "if (UNLIKELY (dump_file && (dump_flags & TDF_FOLDING))) " - "fprintf (dump_file, \"%s ", - s->kind == simplify::SIMPLIFY - ? "Applying pattern" : "Matching expression"); - fprintf (f, "%%s:%%d, %%s:%%d\\n\", "); + fprintf_indent (f, indent, "if (UNLIKELY (dump_folding_p)) " + "dump_debug (%s, ", s->kind == simplify::SIMPLIFY ? "true" : "false"); output_line_directive (f, result ? result->location : s->match->location, true, - true); + true, true); fprintf (f, ", __FILE__, __LINE__);\n"); fprintf_indent (f, indent, "{\n"); diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc index ec603f9d043c3924ea442bb49b5300a3573503cf..ae0c5c8a74fd9f1acdb616014941b11961e96c04 100644 --- a/gcc/gimple-match-head.cc +++ b/gcc/gimple-match-head.cc @@ -1412,3 +1412,17 @@ get_conditional_internal_fn (code_helper code, tree type) auto cfn = combined_fn (code); return get_conditional_internal_fn (associated_internal_fn (cfn, type)); } + +/* Helper method for debug printing to reducing string parsing overhead. Keep + in sync with version in generic-match-head.cc. */ + +static +void dump_debug (bool simplify, int loc, const char *file, int lineno) +{ + if (simplify) + fprintf (dump_file, "Applying pattern %s:%d, %s:%d\n", "match.pd", loc, + file, lineno); + else + fprintf (dump_file, "Matching expression %s:%d, %s:%d\n", "match.pd", loc, + file, lineno); +} \ No newline at end of file -- --m9203EutozRHsPpK Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="rb17158.patch" diff --git a/gcc/dumpfile.h b/gcc/dumpfile.h index 7d5eca899dcc98676a9ce7a7efff8e439854ff89..e7b595ddecdcca9983d9584b8b2417ae1941c7d4 100644 --- a/gcc/dumpfile.h +++ b/gcc/dumpfile.h @@ -522,6 +522,7 @@ parse_dump_option (const char *, const char **); extern FILE *dump_file; extern dump_flags_t dump_flags; extern const char *dump_file_name; +extern bool dump_folding_p; extern bool dumps_are_enabled; diff --git a/gcc/dumpfile.cc b/gcc/dumpfile.cc index 51f68c8c6b40051ba3125c84298ee44ca52f5d17..f805aa73f3aa244d847149eec26505181ce4efe8 100644 --- a/gcc/dumpfile.cc +++ b/gcc/dumpfile.cc @@ -63,6 +63,7 @@ FILE *dump_file = NULL; const char *dump_file_name; dump_flags_t dump_flags; bool dumps_are_enabled = false; +bool dump_folding_p = false; /* Set global "dump_file" to NEW_DUMP_FILE, refreshing the "dumps_are_enabled" @@ -73,6 +74,7 @@ set_dump_file (FILE *new_dump_file) { dumpfile_ensure_any_optinfo_are_flushed (); dump_file = new_dump_file; + dump_folding_p = dump_file && (dump_flags & TDF_FOLDING); dump_context::get ().refresh_dumps_are_enabled (); } diff --git a/gcc/generic-match-head.cc b/gcc/generic-match-head.cc index f011204c5be450663231bdece0596317b37f9f9b..16b8f9f3b61d3d5651a5a41a8c0552f50b55cc7c 100644 --- a/gcc/generic-match-head.cc +++ b/gcc/generic-match-head.cc @@ -102,3 +102,17 @@ optimize_successive_divisions_p (tree, tree) { return false; } + +/* Helper method for debug printing to reducing string parsing overhead. Keep + in sync with version in gimple-match-head.cc. */ + +static +void dump_debug (bool simplify, int loc, const char *file, int lineno) +{ + if (simplify) + fprintf (dump_file, "Applying pattern %s:%d, %s:%d\n", "match.pd", loc, + file, lineno); + else + fprintf (dump_file, "Matching expression %s:%d, %s:%d\n", "match.pd", loc, + file, lineno); +} \ No newline at end of file diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc index 638606b2502f640e59527fc5a0b23fa3bedd0cee..bd7c6ff4a3fb89d456b02242707fd823b737f20d 100644 --- a/gcc/genmatch.cc +++ b/gcc/genmatch.cc @@ -185,7 +185,8 @@ fprintf_indent (FILE *f, unsigned int indent, const char *format, ...) static void output_line_directive (FILE *f, location_t location, - bool dumpfile = false, bool fnargs = false) + bool dumpfile = false, bool fnargs = false, + bool loc_only = false) { const line_map_ordinary *map; linemap_resolve_location (line_table, location, LRK_SPELLING_LOCATION, &map); @@ -204,7 +205,9 @@ output_line_directive (FILE *f, location_t location, else ++file; - if (fnargs) + if (loc_only) + fprintf (f, "%d", loc.line); + else if (fnargs) fprintf (f, "\"%s\", %d", file, loc.line); else fprintf (f, "%s:%d", file, loc.line); @@ -3431,14 +3434,11 @@ dt_simplify::gen_1 (FILE *f, int indent, bool gimple, operand *result) needs_label = true; } - fprintf_indent (f, indent, "if (UNLIKELY (dump_file && (dump_flags & TDF_FOLDING))) " - "fprintf (dump_file, \"%s ", - s->kind == simplify::SIMPLIFY - ? "Applying pattern" : "Matching expression"); - fprintf (f, "%%s:%%d, %%s:%%d\\n\", "); + fprintf_indent (f, indent, "if (UNLIKELY (dump_folding_p)) " + "dump_debug (%s, ", s->kind == simplify::SIMPLIFY ? "true" : "false"); output_line_directive (f, result ? result->location : s->match->location, true, - true); + true, true); fprintf (f, ", __FILE__, __LINE__);\n"); fprintf_indent (f, indent, "{\n"); diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc index ec603f9d043c3924ea442bb49b5300a3573503cf..ae0c5c8a74fd9f1acdb616014941b11961e96c04 100644 --- a/gcc/gimple-match-head.cc +++ b/gcc/gimple-match-head.cc @@ -1412,3 +1412,17 @@ get_conditional_internal_fn (code_helper code, tree type) auto cfn = combined_fn (code); return get_conditional_internal_fn (associated_internal_fn (cfn, type)); } + +/* Helper method for debug printing to reducing string parsing overhead. Keep + in sync with version in generic-match-head.cc. */ + +static +void dump_debug (bool simplify, int loc, const char *file, int lineno) +{ + if (simplify) + fprintf (dump_file, "Applying pattern %s:%d, %s:%d\n", "match.pd", loc, + file, lineno); + else + fprintf (dump_file, "Matching expression %s:%d, %s:%d\n", "match.pd", loc, + file, lineno); +} \ No newline at end of file --m9203EutozRHsPpK--