From patchwork Thu Apr 17 08:05:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 339808 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 8F14D14008E for ; Thu, 17 Apr 2014 18:06:56 +1000 (EST) 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=wYuILBJzvyPzjI17T4OEKh+8ZGw/6XQ/0bFy+kQKHfpAD5SSv5TFl krpJQuSGiBYAN8/P0fe97ASM3S1PcM5TkLBk/FyIhSQ7x0lJosM3hi9XJY8vxP7U /Kc1b0v1aEUOaYF5x3U3Rz/7TotRF9J+kIqZ2hgZlww8hW2rh8c++g= 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:subject:message-id:mime-version:content-type; s= default; bh=acnCTE6zb4lk4/cig4Cc7d7BANo=; b=TK2pXpavA15BVcxlmc8e iVSB6K1pK7IwmDu0S1wgX8gt4mOzXLqIdsRgzmPvn7a4kij+lMeWw56PNidA9siW bcwwYHIGvsOVueYOTJ8Hc6ePT8BDnGFc1o6beWdIpU5pnxHxmRqfququFgYED0fb LzuwxXkHYkuM7rvbSufEsgc= Received: (qmail 9249 invoked by alias); 17 Apr 2014 08:06:49 -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 9235 invoked by uid 89); 17 Apr 2014 08:06:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 17 Apr 2014 08:06:48 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 533F5ACE0 for ; Thu, 17 Apr 2014 08:06:45 +0000 (UTC) Date: Thu, 17 Apr 2014 10:05:04 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR60849 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 This fixes PR60849 by properly rejecting non-boolean typed comparisons from valid_gimple_rhs_p so they go through the gimplification paths. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2014-04-16 Richard Biener PR middle-end/60849 * tree-ssa-propagate.c (valid_gimple_rhs_p): Only allow effective boolean results for comparisons. * g++.dg/opt/pr60849.C: New testcase. Index: gcc/tree-ssa-propagate.c =================================================================== --- gcc/tree-ssa-propagate.c (revision 209423) +++ gcc/tree-ssa-propagate.c (working copy) @@ -571,8 +571,14 @@ valid_gimple_rhs_p (tree expr) /* All constants are ok. */ break; - case tcc_binary: case tcc_comparison: + if (!INTEGRAL_TYPE_P (TREE_TYPE (expr)) + || (TREE_CODE (TREE_TYPE (expr)) != BOOLEAN_TYPE + && TYPE_PRECISION (TREE_TYPE (expr)) != 1)) + return false; + + /* Fallthru. */ + case tcc_binary: if (!is_gimple_val (TREE_OPERAND (expr, 0)) || !is_gimple_val (TREE_OPERAND (expr, 1))) return false; Index: gcc/testsuite/g++.dg/opt/pr60849.C =================================================================== --- gcc/testsuite/g++.dg/opt/pr60849.C (revision 0) +++ gcc/testsuite/g++.dg/opt/pr60849.C (working copy) @@ -0,0 +1,13 @@ +// { dg-do compile } +// { dg-options "-O2" } + +int g; + +extern "C" int isnan (); + +void foo(float a) { + int (*xx)(...); + xx = isnan; + if (xx(a)) + g++; +}