From patchwork Sun Jul 14 08:14:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rubin Gerritsen X-Patchwork-Id: 1960282 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=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WMJ735ZPmz1xqc for ; Sun, 14 Jul 2024 18:15:43 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3D8E384DD00 for ; Sun, 14 Jul 2024 08:15:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by sourceware.org (Postfix) with ESMTPS id 38572385843B for ; Sun, 14 Jul 2024 08:14:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38572385843B Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=hotmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 38572385843B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720944906; cv=none; b=gUE01323cqEe+l7v3gt1jR96Dj7F4c5BKpxY4vQmYGJYgKCfNTxUB3E1IU1ZKgUwpIfDs6ExQp8vfk40IMcF6JLuNngMKQso06xSvz6DTt7KBJzM3dHy1EX1hpzRE0smgIhV2RF4z87CNB40l8l/nTJmW1mkkZwlN6srJOtegb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720944906; c=relaxed/simple; bh=kE7ivUeoX+FFzGkxktR0Q5k+gkTXUS+Jat47WGDoiCo=; h=MIME-Version:From:Date:Message-ID:Subject:To; b=fby8bhTwXNXPUqW1I/HJL6jfbuKWQaLUHtjCl29UEyu+gd3cygu1hg53b1WGTJw2zCKjaAF+oCX07q6xx1B0TXSe2L0QiiySq76UzVNr4aGJeK1m4vNeuUc47ScmWS286Xl5ELbWcscKi9vX6PKYGG4rL7s9UDMx3Ll4kwokZ4U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-367993463b8so1883566f8f.2 for ; Sun, 14 Jul 2024 01:14:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720944890; x=1721549690; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=CBbw8RB574qhOceOab4vDBB47uFPTCzRKyvegv+Cz8A=; b=ZDW/7I8YATeEoP+CAyW78EOaSZOV/N1Jl0Hy6o/WWiF3+Zo6Ke8Vdr0rW+xF2sWelJ oTIFc/07AC+p7qBPL0s32I389/xvCgHsbvm4RJqmNiRel7LvtBLxlVIP23LM4U2mEpMm N0n7YG8nGP9GrrFnHOAXz6coaaZvudaaX7pt6moJ5rpfLpPd9eIk/+/IFtTy370p9nlm +//ug20WDs3WpsOfYzrNG7d3CEnZwPku6MSlth0iCY3mtBFSayBFehYkIHVkhrkFH7Y4 qaLjcj6CApOoTmpr/4Vw6+nt1Vlk6QVy5dnUGh17fcjFuYeUrRGVGsKXWPv/3zXixb3S 3BkQ== X-Gm-Message-State: AOJu0YyYx/yOE8w+N4k/5hXrmLJrJq6+aHMe+cfZ+Sm/8wBxzCTruQ11 q8CZoOSYcGRo+8iCpsp1dUk2ngpzBOKSQgNpUkt4pCNPSrjJVRDESmC+3WiztCkNpmg/grQi3c+ 22Q2iLwQ9wqSI3PpxdkEVvNfMsvnEuVZs X-Google-Smtp-Source: AGHT+IHMxFVDQC7kVA31V/lz7a2q/Ed9e6dcUnOlPrbIyCXG3s0o2qP0l8IalcihAvUyq4hWpspasVLgnCU+lTpXSxw= X-Received: by 2002:a5d:4a4b:0:b0:35f:2030:d42c with SMTP id ffacd0b85a97d-367cea6b7a0mr9941677f8f.17.1720944889724; Sun, 14 Jul 2024 01:14:49 -0700 (PDT) MIME-Version: 1.0 From: "rubin.gerritsen" Date: Sun, 14 Jul 2024 10:14:36 +0200 Message-ID: Subject: [PATCH] gimple-fold: consistent dump of builtin call simplifications To: gcc-patches@gcc.gnu.org X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, FORGED_HOTMAIL_RCVD2, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Previously only simplifications of the `__st[xrp]cpy_chk` were dumped. Now all call replacement simplifications are dumped. Examples of statements with corresponding dumpfile entries: `printf("mystr\n");`: optimized: simplified printf to __builtin_puts `printf("%c", 'a');`: optimized: simplified printf to __builtin_putchar `printf("%s\n", "mystr");`: optimized: simplified printf to __builtin_puts 2024-07-13 Rubin Gerritsen gcc/ChangeLog: * gimple-fold.cc (dump_transformation): Moved definition. (replace_call_with_call_and_fold): Calls dump_transformation. (gimple_fold_builtin_stxcpy_chk): Removes call to dump_transformation, now in replace_call_with_call_and_fold. (gimple_fold_builtin_stxncpy_chk): Removes call to dump_transformation, now in replace_call_with_call_and_fold. Signed-off-by: Rubin Gerritsen --- gcc/gimple-fold.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) /* Replace the call at *GSI with the gimple value VAL. */ @@ -835,6 +844,7 @@ static void replace_call_with_call_and_fold (gimple_stmt_iterator *gsi, gimple *repl) { gimple *stmt = gsi_stmt (*gsi); + dump_transformation (as_a (stmt), as_a (repl)); gimple_call_set_lhs (repl, gimple_call_lhs (stmt)); gimple_set_location (repl, gimple_location (stmt)); gimple_move_vops (repl, stmt); @@ -3090,16 +3100,6 @@ gimple_fold_builtin_memory_chk (gimple_stmt_iterator *gsi, return true; } -/* Print a message in the dump file recording transformation of FROM to TO. */ - -static void -dump_transformation (gcall *from, gcall *to) -{ - if (dump_enabled_p ()) - dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, from, "simplified %T to %T\n", - gimple_call_fn (from), gimple_call_fn (to)); -} - /* Fold a call to the __st[rp]cpy_chk builtin. DEST, SRC, and SIZE are the arguments to the call. IGNORE is true if return value can be ignored. FCODE is the BUILT_IN_* @@ -3189,7 +3189,6 @@ gimple_fold_builtin_stxcpy_chk (gimple_stmt_iterator *gsi, return false; gcall *repl = gimple_build_call (fn, 2, dest, src); - dump_transformation (stmt, repl); replace_call_with_call_and_fold (gsi, repl); return true; } @@ -3235,7 +3234,6 @@ gimple_fold_builtin_stxncpy_chk (gimple_stmt_iterator *gsi, return false; gcall *repl = gimple_build_call (fn, 3, dest, src, len); - dump_transformation (stmt, repl); replace_call_with_call_and_fold (gsi, repl); return true; } diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc index 7c534d56bf1..b20d3a2ff9a 100644 --- a/gcc/gimple-fold.cc +++ b/gcc/gimple-fold.cc @@ -802,6 +802,15 @@ gimplify_and_update_call_from_tree (gimple_stmt_iterator *si_p, tree expr) gsi_replace_with_seq_vops (si_p, stmts); } +/* Print a message in the dump file recording transformation of FROM to TO. */ + +static void +dump_transformation (gcall *from, gcall *to) +{ + if (dump_enabled_p ()) + dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, from, "simplified %T to %T\n", + gimple_call_fn (from), gimple_call_fn (to)); +}