From patchwork Mon May 23 16:56:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 97016 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]) by ozlabs.org (Postfix) with SMTP id 627D7B6FB8 for ; Tue, 24 May 2011 02:56:26 +1000 (EST) Received: (qmail 2223 invoked by alias); 23 May 2011 16:56:22 -0000 Received: (qmail 2215 invoked by uid 22791); 23 May 2011 16:56:21 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 May 2011 16:56:08 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4NGu7vp018372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 May 2011 12:56:07 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p4NGu6cr012096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 23 May 2011 12:56:07 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p4NGu6gu002678 for ; Mon, 23 May 2011 18:56:06 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p4NGu62i002676 for gcc-patches@gcc.gnu.org; Mon, 23 May 2011 18:56:06 +0200 Date: Mon, 23 May 2011 18:56:06 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [4.6 PATCH] Fix pr48973-{1,2}.c testcases with LTO (PR lto/49123) Message-ID: <20110523165605.GD17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 Hi! This is something I didn't notice in my testing because my ld doesn't support plugins and thus -flto didn't act as -fwhole-file. The bug got fixed on the trunk by changing build_int_cst, which is too risky to backport, so this patch instead just adjusts the single place relevant to this patch to use build_int_cst_type instead. Although it is very likely type is always non-NULL, I haven't proved it and I'm trying to play safe on the release branch and thus kept build_int_cst in the case type would be NULL. The testcase doesn't use -flto, instead if makes the vars static which results in the same thing as -fwhole-file or -flto with linker plugin. Bootstrapped/regtested on the 4.6 branch on x86_64-linux and i686-linux, ok for 4.6 and the testcase also for trunk? 2011-05-23 Jakub Jelinek PR lto/49123 * fold-const.c (constant_boolean_node): If type is non-NULL, use build_int_cst_type instead of build_int_cst. * gcc.c-torture/execute/pr49123.c: New test. Jakub --- gcc/fold-const.c.jj 2011-05-04 10:46:52.000000000 +0200 +++ gcc/fold-const.c 2011-05-23 16:19:13.000000000 +0200 @@ -5953,8 +5953,10 @@ constant_boolean_node (int value, tree t return value ? integer_one_node : integer_zero_node; else if (type == boolean_type_node) return value ? boolean_true_node : boolean_false_node; + else if (type) + return build_int_cst_type (type, value); else - return build_int_cst (type, value); + return build_int_cst (NULL_TREE, value); } --- gcc/testsuite/gcc.c-torture/execute/pr49123.c.jj 2011-05-23 16:15:25.000000000 +0200 +++ gcc/testsuite/gcc.c-torture/execute/pr49123.c 2011-05-23 16:12:59.000000000 +0200 @@ -0,0 +1,14 @@ +/* PR lto/49123 */ + +extern void abort (void); +static struct S { int f : 1; } s; +static int v = -1; + +int +main () +{ + s.f = v < 0; + if ((unsigned int) s.f != -1U) + abort (); + return 0; +}