From patchwork Wed Feb 9 08:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 50945 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 40E38385840B for ; Wed, 9 Feb 2022 08:52:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40E38385840B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1644396762; bh=9fON8VTpO+eA78CxDBIbZQaXeqZ1Wb00MSXP17RjZog=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=MFlyYZRAda0MLBzQZUMY9MFoHINbuaDgx/PLPFWVEsu5U4e0xKkVhZFB46lXeHNS3 BTI0soyuoogZgn9NE7PPh59GIXSQFc8RjuoNJdCqFVEo5JAJGLL4XTg+CVMOjDajwM 5L9ibQpSyr2DUTOZ27wo6p8tp9dXbVQTftcKDtJk= 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 C10C23858D20 for ; Wed, 9 Feb 2022 08:52:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C10C23858D20 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-52-FfcBQgnrO3qyQn2ds9Fr0w-1; Wed, 09 Feb 2022 03:52:09 -0500 X-MC-Unique: FfcBQgnrO3qyQn2ds9Fr0w-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54267101F7C1; Wed, 9 Feb 2022 08:52:08 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDE5E5ED55; Wed, 9 Feb 2022 08:52:07 +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 2198q4HP1085990 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 9 Feb 2022 09:52:05 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 2198q3fk1085989; Wed, 9 Feb 2022 09:52:03 +0100 Date: Wed, 9 Feb 2022 09:52:03 +0100 To: "Joseph S. Myers" , Marek Polacek Subject: [PATCH] c: Fix up __builtin_assoc_barrier handling in the C FE [PR104427] Message-ID: <20220209085203.GL2646553@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! The following testcase ICEs, because when creating PAREN_EXPR for __builtin_assoc_barrier the FE doesn't do the usual tweaks for EXCESS_PRECISION_EXPR or C_MAYBE_CONST_EXPR. I believe that the declared effect of the builtin is just association barrier, so e.g. excess precision should be still handled like if it wasn't there. The following patch uses build_unary_op to handle those. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-02-08 Jakub Jelinek PR c/104427 * c-parser.cc (c_parser_postfix_expression) : Use parser_build_unary_op instead of build1_loc to build PAREN_EXPR. * c-typeck.cc (build_unary_op): Handle PAREN_EXPR. * c-fold.cc (c_fully_fold_internal): Likewise. * gcc.dg/pr104427.c: New test. Jakub --- gcc/c/c-parser.cc.jj 2022-01-18 11:58:58.927991414 +0100 +++ gcc/c/c-parser.cc 2022-02-08 12:56:00.028208794 +0100 @@ -10128,8 +10128,7 @@ c_parser_postfix_expression (c_parser *p mark_exp_read (e1.value); location_t end_loc = c_parser_peek_token (parser)->get_finish (); parens.skip_until_found_close (parser); - expr.value = build1_loc (loc, PAREN_EXPR, TREE_TYPE (e1.value), - e1.value); + expr = parser_build_unary_op (loc, PAREN_EXPR, e1); set_c_expr_source_range (&expr, start_loc, end_loc); } break; --- gcc/c/c-typeck.cc.jj 2022-01-18 11:58:58.929991386 +0100 +++ gcc/c/c-typeck.cc 2022-02-08 12:53:16.026485823 +0100 @@ -4921,6 +4921,10 @@ build_unary_op (location_t location, enu ret = val; goto return_build_unary_op; + case PAREN_EXPR: + ret = build1 (code, TREE_TYPE (arg), arg); + goto return_build_unary_op; + default: gcc_unreachable (); } --- gcc/c/c-fold.cc.jj 2022-01-18 11:58:58.925991443 +0100 +++ gcc/c/c-fold.cc 2022-02-08 12:37:46.315411262 +0100 @@ -465,6 +465,7 @@ c_fully_fold_internal (tree expr, bool i case BIT_NOT_EXPR: case TRUTH_NOT_EXPR: case CONJ_EXPR: + case PAREN_EXPR: unary: /* Unary operations. */ orig_op0 = op0 = TREE_OPERAND (expr, 0); --- gcc/testsuite/gcc.dg/pr104427.c.jj 2022-02-08 13:08:14.054022838 +0100 +++ gcc/testsuite/gcc.dg/pr104427.c 2022-02-08 13:08:41.541641923 +0100 @@ -0,0 +1,13 @@ +/* PR c/104427 */ +/* { dg-do compile } */ +/* { dg-options "" } */ +/* { dg-add-options float16 } */ +/* { dg-require-effective-target float16 } */ + +_Float16 x, y; + +int +foo () +{ + return __builtin_assoc_barrier (x + y) - y; +}