From patchwork Thu Oct 6 08:42:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1756 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp205043wrs; Thu, 6 Oct 2022 01:43:33 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6PqXSczFWoGDsVxazj/aeBw/6WIBQrF8Cz42Ybq2kGooCY1ITwc69dmX4jmrD+VR0/K3bG X-Received: by 2002:a05:6402:190f:b0:459:aa70:9def with SMTP id e15-20020a056402190f00b00459aa709defmr3457065edz.289.1665045813866; Thu, 06 Oct 2022 01:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665045813; cv=none; d=google.com; s=arc-20160816; b=RvJpMAm0NA+qO9Q5pL+BcEcxJx3+35gBizsGX5Z6KPHY/Y3VCAhHeGXlCA9oBo2gEv tdEee+jSoBTqiwJu7TNXxLkFww8KCpgVpMe4ymM2GGFZsQQeAK2nMYh+6s4LmbfA8Svh +ZgrXErtdo4SUGfHcoQ1/mypPHuvyeWpIqmhCJhkAWBmz3gk/jB2CJNRgSqnHty30Jza LABKtgt8VGlxs5ZNaQ3UdYtA1jndZLcWSCiDEtlcHbY3mWZjSjOregGs5T3RS1AzQYim mQjQRjRbRvDDBfRTPV2EUGC+5/xqm9J/zj9TAvj/zMlU/iW7hYOiivpLvtDWeBiSAqcZ vncQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=EhdaInrqx41b1TO2j4iSkXxCjQnG1qLj+68iAO9fN7Y=; b=TmaLFxOpeavdW8esCk+7LJcukpeMowRw8mdLFF8k+5hPGCmx53LIb4ROacWz5CmPHs 0bIGzJ6g1G1ioXVHZqUVIySJPAIHgUcaSRInqJ3ViM6SYVgq/UPNRbDG0MtmM52j0Cx8 8oMv0Je5XSZVrDm97CstfwwnkMRin5Lze6KCpwS+7HD/flaDEWqcj6Ug3Nhz+Z3QAzMV PDspacTKUmhmjhoWWV/PF0is86BoIB7I+nLfKP9b+Kr9OD2B7KD8nLe1jnoBqAzIWK7d uQR+dHoNKjYE9SU5FOjGRdsO+GL2qyUDxJtaDtoBWSbLW5W+JVa1aLBeaUX5pzgxJO+q Jy3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JMEqU11X; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id sh33-20020a1709076ea100b0075c4337b02dsi17321206ejc.827.2022.10.06.01.43.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 01:43:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=JMEqU11X; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E98893865493 for ; Thu, 6 Oct 2022 08:43:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E98893865493 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665045812; bh=EhdaInrqx41b1TO2j4iSkXxCjQnG1qLj+68iAO9fN7Y=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=JMEqU11XVbLEj15qLMmHWm3yBQEsTgHvkeH8KM99Rgv7ZNoSmn5ovMw8O84Ozu3vt CBqO07QJU042a/IZdqdjojqNiaMNQ/UvnrjY3LD7Q4hQcLse9pY+NccVf2FznmPFEh Fsnv527/LArqfKBMNg9rxnG4L+V2arHM8s9x1lHo= 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 4B6D6384D141 for ; Thu, 6 Oct 2022 08:42:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4B6D6384D141 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-118-7NLeSAYgPAiINiusQJzvHg-1; Thu, 06 Oct 2022 04:42:46 -0400 X-MC-Unique: 7NLeSAYgPAiINiusQJzvHg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 816AD2932499; Thu, 6 Oct 2022 08:42:46 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.194]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 308AF39DB3; Thu, 6 Oct 2022 08:42:46 +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 2968gh691782506 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 6 Oct 2022 10:42:43 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2968ggqX1782505; Thu, 6 Oct 2022 10:42:42 +0200 Date: Thu, 6 Oct 2022 10:42:42 +0200 To: gcc-patches@gcc.gnu.org Subject: [committed] openmp: Map holds clause to IFN_ASSUME for C/C++ Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline 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, 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 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: Tobias Burnus Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745927079329313804?= X-GMAIL-MSGID: =?utf-8?q?1745927079329313804?= Hi! Now that [[assume (cond)]] support is in, this simple patch makes #pragma omp assume holds(cond) use it. Committed to trunk. 2022-10-06 Jakub Jelinek * c-parser.cc (c_parser_omp_assumption_clauses): Emit IFN_ASSUME call for holds clause on assume construct. * parser.cc (cp_parser_omp_assumption_clauses): Emit IFN_ASSUME call for holds clause on assume construct. * c-c++-common/gomp/assume-4.c: New test. Jakub --- gcc/c/c-parser.cc.jj 2022-10-06 08:56:28.570128568 +0200 +++ gcc/c/c-parser.cc 2022-10-06 10:07:25.596420330 +0200 @@ -23571,10 +23571,12 @@ c_parser_omp_assumption_clauses (c_parse tree t = convert_lvalue_to_rvalue (eloc, expr, true, true).value; t = c_objc_common_truthvalue_conversion (eloc, t); t = c_fully_fold (t, false, NULL); - if (is_assume) + if (is_assume && t != error_mark_node) { - /* FIXME: Emit .ASSUME (t) call here. */ - (void) t; + tree fn = build_call_expr_internal_loc (eloc, IFN_ASSUME, + void_type_node, 1, + t); + add_stmt (fn); } parens.skip_until_found_close (parser); } --- gcc/cp/parser.cc.jj 2022-10-06 08:56:28.625127823 +0200 +++ gcc/cp/parser.cc 2022-10-06 10:20:35.452732109 +0200 @@ -46023,13 +46023,15 @@ cp_parser_omp_assumption_clauses (cp_par matching_parens parens; if (parens.require_open (parser)) { + location_t eloc = cp_lexer_peek_token (parser->lexer)->location; tree t = cp_parser_assignment_expression (parser); if (!type_dependent_expression_p (t)) t = contextual_conv_bool (t, tf_warning_or_error); - if (is_assume) + if (is_assume && !error_operand_p (t)) { - /* FIXME: Emit .ASSUME (t) call here. */ - (void) t; + t = build_call_expr_internal_loc (eloc, IFN_ASSUME, + void_type_node, 1, t); + finish_expr_stmt (t); } if (!parens.require_close (parser)) cp_parser_skip_to_closing_parenthesis (parser, --- gcc/testsuite/c-c++-common/gomp/assume-4.c.jj 2022-10-06 10:17:58.028862432 +0200 +++ gcc/testsuite/c-c++-common/gomp/assume-4.c 2022-10-06 10:23:41.011221059 +0200 @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "return 42;" 2 "optimized" } } */ +/* { dg-final { scan-tree-dump-not "return -1;" "optimized" } } */ + +int +foo (int x) +{ + int y; + #pragma omp assume holds (x == 42) + y = x; + return y; +} + +int +bar (int x) +{ + #pragma omp assume holds (x < 42) + ; + if (x == 42) + return -1; + return 42; +}