From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113601 invoked by alias); 14 Sep 2017 10:55:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 113426 invoked by uid 89); 14 Sep 2017 10:55:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy=22am, 22AM X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 14 Sep 2017 10:55:09 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B779C0587C4; Thu, 14 Sep 2017 10:55:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5B779C0587C4 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jakub@redhat.com Received: from tucnak.zalov.cz (ovpn-116-33.ams2.redhat.com [10.36.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 051A75C66F; Thu, 14 Sep 2017 10:55:07 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v8EAt5R5010260; Thu, 14 Sep 2017 12:55:05 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v8EAt3ph010259; Thu, 14 Sep 2017 12:55:03 +0200 Date: Thu, 14 Sep 2017 10:55:00 -0000 From: Jakub Jelinek To: Tom de Vries Cc: GCC Patches Subject: Re: [PATCH, PR81844] Fix condition folding in c_parser_omp_for_loop Message-ID: <20170914105503.GH1701@tucnak> Reply-To: Jakub Jelinek References: <8d91b179-6873-2988-529b-705e123010cf@mentor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8d91b179-6873-2988-529b-705e123010cf@mentor.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00878.txt.bz2 On Mon, Aug 14, 2017 at 10:25:22AM +0200, Tom de Vries wrote: > 2017-08-14 Tom de Vries > > PR c/81844 Please use PR c/81875 instead, now that you've filed it. > * c-parser.c (c_parser_omp_for_loop): Fix condition folding. Fold only operands of cond, not cond itself. ? > * testsuite/libgomp.c/pr81805.c: New test. Wouldn't it be worth to test it also for C++? I know we don't have libgomp.c-c++-common (maybe we should add that), so the current way would be add libgomp.c++/pr81805.C that #includes the other test source (if you tweak it for C++, it would need #ifdef __cplusplus "C" #endif for abort). > --- a/gcc/c/c-parser.c > +++ b/gcc/c/c-parser.c > @@ -15027,7 +15027,24 @@ c_parser_omp_for_loop (location_t loc, c_parser *parser, enum tree_code code, > > cond = cond_expr.value; > cond = c_objc_common_truthvalue_conversion (cond_loc, cond); > - cond = c_fully_fold (cond, false, NULL); > + switch (TREE_CODE (cond)) Just do if (COMPARISON_CLASS_P (cond)) instead of the switch? > + { > + case GT_EXPR: > + case GE_EXPR: > + case LT_EXPR: > + case LE_EXPR: > + case NE_EXPR: > + { > + tree op0 = TREE_OPERAND (cond, 0), op1 = TREE_OPERAND (cond, 1); > + op0 = c_fully_fold (op0, false, NULL); > + op1 = c_fully_fold (op1, false, NULL); > + TREE_OPERAND (cond, 0) = op0; > + TREE_OPERAND (cond, 1) = op1; > + } > + break; > + default: > + break; > + } > switch (cond_expr.original_code) > { > case GT_EXPR: Ok with those changes and sorry for the review delay. Jakub