From patchwork Fri Feb 11 11:36:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1591599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=w1vCOnIk; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JwBR60Y5lz9s0r for ; Fri, 11 Feb 2022 22:36:49 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 015403858036 for ; Fri, 11 Feb 2022 11:36:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 015403858036 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1644579407; bh=FAEIKsOyPZYSFcxyCXIoP++Xmyk/a+c7sWMKPxTv8dQ=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=w1vCOnIk6ySg13CyVBZ1i7uzRUbBGdJaRndB8aez0VNE8+dwTKwkWkkKls7iy2fPA PbVJtdWEInEzEDND49xTSuSMmkQeOQD7BEB04+bjy2UQrLYDGsd8c1Wj588CDm46lq F01Cw5qSQYYesGMr4rLhDPJZEvHylA4kkEvi6TP4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 43936385843F for ; Fri, 11 Feb 2022 11:36:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 43936385843F Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-zMWejnqOOC6dqJErTHtcIQ-1; Fri, 11 Feb 2022 06:36:18 -0500 X-MC-Unique: zMWejnqOOC6dqJErTHtcIQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5C5D814243; Fri, 11 Feb 2022 11:36:17 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D1E08049B; Fri, 11 Feb 2022 11:36:17 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 21BBaEha2436361 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Feb 2022 12:36:14 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 21BBaDm12436360; Fri, 11 Feb 2022 12:36:13 +0100 Date: Fri, 11 Feb 2022 12:36:13 +0100 To: Richard Biener Subject: [PATCH] middle-end: Small __builtin_clear_padding improvements Message-ID: <20220211113613.GQ2646553@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi! When looking at __builtin_clear_padding today, I've noticed that it is quite wasteful to extend the original user one argument to 3, 2 is enough. We need to encode the original type of the first argument because pointer conversions are useless in GIMPLE, and we need to record a boolean whether it is for -ftrivial-auto-var-init=* or not. But for recording the type we don't need the value (we've always used zero) and for recording the boolean we don't need the type (we've always used integer_type_node). So, this patch merges the two into one. Ok for trunk if it passes full bootstrap/regtest? 2022-02-11 Jakub Jelinek * tree.cc (build_common_builtin_nodes): Fix up formatting in __builtin_clear_padding decl creation. * gimplify.cc (gimple_add_padding_init_for_auto_var): Encode for_auto_init in the value of 2nd BUILT_IN_CLEAR_PADDING argument rather than in 3rd argument. (gimplify_call_expr): Likewise. Fix up comment formatting. * gimple-fold.cc (gimple_fold_builtin_clear_padding): Expect 2 arguments instead of 3, take for_auto_init from the value of 2nd argument. Jakub --- gcc/tree.cc.jj 2022-02-11 00:19:22.436063200 +0100 +++ gcc/tree.cc 2022-02-11 12:15:00.929134203 +0100 @@ -9520,7 +9520,7 @@ build_common_builtin_nodes (void) local_define_builtin ("__builtin_clear_padding", ftype, BUILT_IN_CLEAR_PADDING, "__builtin_clear_padding", - ECF_LEAF | ECF_NOTHROW); + ECF_LEAF | ECF_NOTHROW); } if (!builtin_decl_explicit_p (BUILT_IN_UNREACHABLE) --- gcc/gimplify.cc.jj 2022-02-11 00:19:22.305064981 +0100 +++ gcc/gimplify.cc 2022-02-11 12:17:22.679180223 +0100 @@ -1804,7 +1804,6 @@ gimple_add_padding_init_for_auto_var (tr gimple_seq *seq_p) { tree addr_of_decl = NULL_TREE; - bool for_auto_init = true; tree fn = builtin_decl_explicit (BUILT_IN_CLEAR_PADDING); if (is_vla) @@ -1821,11 +1820,8 @@ gimple_add_padding_init_for_auto_var (tr addr_of_decl = build_fold_addr_expr (decl); } - gimple *call = gimple_build_call (fn, - 3, addr_of_decl, - build_zero_cst (TREE_TYPE (addr_of_decl)), - build_int_cst (integer_type_node, - (int) for_auto_init)); + gimple *call = gimple_build_call (fn, 2, addr_of_decl, + build_one_cst (TREE_TYPE (addr_of_decl))); gimplify_seq_add_stmt (seq_p, call); } @@ -3536,15 +3532,12 @@ gimplify_call_expr (tree *expr_p, gimple { /* Remember the original type of the argument in an internal dummy second argument, as in GIMPLE pointer conversions are - useless. also mark this call as not for automatic initialization - in the internal dummy third argument. */ + useless. Also mark this call as not for automatic + initialization in the internal dummy third argument. */ p = CALL_EXPR_ARG (*expr_p, 0); - bool for_auto_init = false; *expr_p - = build_call_expr_loc (EXPR_LOCATION (*expr_p), fndecl, 3, p, - build_zero_cst (TREE_TYPE (p)), - build_int_cst (integer_type_node, - (int) for_auto_init)); + = build_call_expr_loc (EXPR_LOCATION (*expr_p), fndecl, 2, p, + build_zero_cst (TREE_TYPE (p))); return GS_OK; } break; --- gcc/gimple-fold.cc.jj 2022-02-11 00:18:54.799439055 +0100 +++ gcc/gimple-fold.cc 2022-02-11 12:13:27.869417000 +0100 @@ -4879,10 +4879,10 @@ gimple_fold_builtin_clear_padding (gimpl gcc_assert (gimple_call_num_args (stmt) == 3); tree ptr = gimple_call_arg (stmt, 0); tree typearg = gimple_call_arg (stmt, 1); - /* the 3rd argument of __builtin_clear_padding is to distinguish whether - this call is made by the user or by the compiler for automatic variable - initialization. */ - bool for_auto_init = (bool) TREE_INT_CST_LOW (gimple_call_arg (stmt, 2)); + /* The 2nd argument of __builtin_clear_padding's value is used to + distinguish whether this call is made by the user or by the compiler + for automatic variable initialization. */ + bool for_auto_init = (bool) TREE_INT_CST_LOW (typearg); tree type = TREE_TYPE (TREE_TYPE (typearg)); location_t loc = gimple_location (stmt); clear_padding_struct buf;