From patchwork Thu Mar 15 12:56:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 886214 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-474778-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="CX0v2Jhy"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4027rX3Vtbz9sVd for ; Thu, 15 Mar 2018 23:56:27 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=KY7ecA8fM9q3HCn+CbkdYXjr+7qQaF+AW2oGcK+w7nUaEqAH9V pdmf/rxS3zVScMOOgYcauf+IY41EzWvNGSWoJ7eqhgq1OeXLSx2RF6P3iHDyj0iB 0ehcAErEibMnfOIzVTJvRN9PtERQJKRZM8V0VP0auxOvg6TzUM8rlyC7A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=e4ljKxK0Z6QMfwIr1X9PYjFuATw=; b=CX0v2Jhy296UF/2YfloM ReClmbsr4JlK9chXrX5ZT35drZGlP9lI81ASnTjklda9aR1NIQH426YknKxL+Dnd WLwFErEgLruQ5HuFldhewxIKble3B+Un08FGEVtsRT6iDOmw101j/mN1UNkYAAVs mIxXIJL8MJquyNaMon9onJQ= Received: (qmail 52121 invoked by alias); 15 Mar 2018 12:56:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 51745 invoked by uid 89); 15 Mar 2018 12:56:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 15 Mar 2018 12:56:18 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1815AAD29; Thu, 15 Mar 2018 12:56:16 +0000 (UTC) Date: Thu, 15 Mar 2018 13:56:16 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Jakub Jelinek Subject: [PATCH] Fix PR84873 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following fixes the C familiy gimplification langhook to not introduce tree sharing which isn't valid during gimplification. For the specific case the tree sharing is introduced by fold_binary_op_with_cond and is reached via convert () eventually folding something. I've kept folding constants here but for the rest defer folding to GIMPLE (the gimplifier already folds most generated stmts). Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk and branches? Thanks, Richard. 2018-03-15 Richard Biener PR c/84873 * c-gimplify.c (c_gimplify_expr): Do not fold expressions. * c-c++-common/pr84873.c: New testcase. Index: gcc/c-family/c-gimplify.c =================================================================== --- gcc/c-family/c-gimplify.c (revision 258552) +++ gcc/c-family/c-gimplify.c (working copy) @@ -245,7 +245,15 @@ c_gimplify_expr (tree *expr_p, gimple_se unsigned_type_node) && !types_compatible_p (TYPE_MAIN_VARIANT (TREE_TYPE (*op1_p)), integer_type_node)) - *op1_p = convert (unsigned_type_node, *op1_p); + { + /* ??? Do not use convert () here or fold arbitrary trees + since folding can introduce tree sharing which is not + allowed during gimplification. */ + if (TREE_CODE (*op1_p) == INTEGER_CST) + *op1_p = fold_convert (unsigned_type_node, *op1_p); + else + *op1_p = build1 (NOP_EXPR, unsigned_type_node, *op1_p); + } break; } Index: gcc/testsuite/c-c++-common/pr84873.c =================================================================== --- gcc/testsuite/c-c++-common/pr84873.c (nonexistent) +++ gcc/testsuite/c-c++-common/pr84873.c (working copy) @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-frounding-math" } */ + +int +i1 (int w3, int n9) +{ + return w3 >> ((long int)(1 + 0.1) + -!n9); +}