From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CCB0A3854164 for ; Thu, 6 Oct 2022 12:17:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CCB0A3854164 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665058637; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rxArF3vE5OxBN7Qu9aiF0RoxXl8OTUMzhZ7LeFi4+60=; b=JJt4O7CkF7lF9/eh3rwMGupOzOKpyPOB88SyX7o0+RIeeIk5euxg0yiuCrZbcCkAL6wFN/ l0Gf1AD2BPdZDsy0Z/GLMnvAusX1XdZ+QNwLH3AewYG1vP3LojsAVH4dyL6cX1qgNlNhoh B04QTsbIinkNWLgo7NbxlZD/+r7G0qA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-343-CPz6-uUoPo-v7GV6KSmoqw-1; Thu, 06 Oct 2022 08:17:13 -0400 X-MC-Unique: CPz6-uUoPo-v7GV6KSmoqw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DBEB91C0A108; Thu, 6 Oct 2022 12:17:12 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94CFA49BB67; Thu, 6 Oct 2022 12:17:12 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 296CH9M11786616 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 6 Oct 2022 14:17:09 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 296CH8VD1786615; Thu, 6 Oct 2022 14:17:08 +0200 Date: Thu, 6 Oct 2022 14:17:07 +0200 From: Jakub Jelinek To: Tobias Burnus Cc: gcc-patches , fortran Subject: Re: [Patch] openmp: Map holds clause to IFN_ASSUME for Fortran Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,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 List-Id: On Thu, Oct 06, 2022 at 12:55:01PM +0200, Tobias Burnus wrote: > Same as for C/C++, albeit a tiny bit longer patch. > > I don't know whether it makes sense to handle – in the long run – the > case of se.pre/se.post being nonempty – and, if so, how. I think it is essential not to throw those away, if se.pre or se.post, you can e.g. expand it roughly as C/C++ ({ cond; }), in GENERIC it can be say a TARGET_EXPR with a boolean temporary as slot, where the the initializer will be the se.pre part, followed by MODIFY_EXPR which sets the slot to se.expr value and followed by se.post. I've only started playing with the middle-end changes now, here is what I have and plan to at lower_cf time turn that into essentially bool artificial (args...) { return cond; } and .ASSUME (&artificial, args...); --- gcc/gimplify.cc.jj 2022-10-06 08:56:28.344131629 +0200 +++ gcc/gimplify.cc 2022-10-06 14:04:46.647204910 +0200 @@ -3569,7 +3569,45 @@ gimplify_call_expr (tree *expr_p, gimple fndecl, 0)); return GS_OK; } - /* FIXME: Otherwise expand it specially. */ + /* Temporarily, until gimple lowering, transform + .ASSUME (cond); + into: + guard = .ASSUME (); + if (guard) goto label_true; else label_false; + label_true:; + { + guard = cond; + } + label_false:; + .ASSUME (guard); + such that gimple lowering can outline the condition into + a separate function easily. */ + tree guard = create_tmp_var (boolean_type_node); + gcall *call = gimple_build_call_internal (ifn, 0); + gimple_call_set_nothrow (call, TREE_NOTHROW (*expr_p)); + gimple_set_location (call, loc); + gimple_call_set_lhs (call, guard); + gimple_seq_add_stmt (pre_p, call); + *expr_p = build2 (MODIFY_EXPR, void_type_node, guard, + CALL_EXPR_ARG (*expr_p, 0)); + *expr_p = build3 (BIND_EXPR, void_type_node, NULL, *expr_p, NULL); + tree label_false = create_artificial_label (UNKNOWN_LOCATION); + tree label_true = create_artificial_label (UNKNOWN_LOCATION); + gcond *cond_stmt = gimple_build_cond (NE_EXPR, guard, + boolean_false_node, + label_true, label_false); + gimplify_seq_add_stmt (pre_p, cond_stmt); + gimplify_seq_add_stmt (pre_p, gimple_build_label (label_true)); + push_gimplify_context (); + gimple_seq body = NULL; + gimple *g = gimplify_and_return_first (*expr_p, &body); + pop_gimplify_context (g); + gimplify_seq_add_seq (pre_p, body); + gimplify_seq_add_stmt (pre_p, gimple_build_label (label_false)); + call = gimple_build_call_internal (ifn, 1, guard); + gimple_call_set_nothrow (call, TREE_NOTHROW (*expr_p)); + gimple_set_location (call, loc); + gimple_seq_add_stmt (pre_p, call); return GS_ALL_DONE; } --- gcc/cp/pt.cc.jj 2022-10-06 08:56:28.670127213 +0200 +++ gcc/cp/pt.cc 2022-10-06 13:42:26.632351930 +0200 @@ -21182,6 +21182,8 @@ tsubst_copy_and_build (tree t, ret = error_mark_node; break; } + if (!processing_template_decl) + arg = fold_build_cleanup_point_expr (TREE_TYPE (arg), arg); ret = build_call_expr_internal_loc (EXPR_LOCATION (t), IFN_ASSUME, void_type_node, 1, --- gcc/cp/cp-gimplify.cc.jj 2022-10-06 08:56:28.660127349 +0200 +++ gcc/cp/cp-gimplify.cc 2022-10-06 13:41:54.286789968 +0200 @@ -3117,6 +3117,8 @@ process_stmt_assume_attribute (tree std_ arg = contextual_conv_bool (arg, tf_warning_or_error); if (error_operand_p (arg)) continue; + if (!processing_template_decl) + arg = fold_build_cleanup_point_expr (TREE_TYPE (arg), arg); statement = build_call_expr_internal_loc (attrs_loc, IFN_ASSUME, void_type_node, 1, arg); finish_expr_stmt (statement); --- gcc/cp/parser.cc.jj 2022-10-06 10:39:31.989345921 +0200 +++ gcc/cp/parser.cc 2022-10-06 13:41:28.001145938 +0200 @@ -46029,6 +46029,8 @@ cp_parser_omp_assumption_clauses (cp_par t = contextual_conv_bool (t, tf_warning_or_error); if (is_assume && !error_operand_p (t)) { + if (!processing_template_decl) + t = fold_build_cleanup_point_expr (TREE_TYPE (t), t); t = build_call_expr_internal_loc (eloc, IFN_ASSUME, void_type_node, 1, t); finish_expr_stmt (t); Jakub