From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3724 invoked by alias); 3 Nov 2010 16:57:40 -0000 Received: (qmail 3709 invoked by uid 22791); 3 Nov 2010 16:57:38 -0000 X-SWARE-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL,BAYES_00,TW_TM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 03 Nov 2010 16:57:33 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 061628738D for ; Wed, 3 Nov 2010 17:57:31 +0100 (CET) Date: Wed, 03 Nov 2010 17:10:00 -0000 From: Richard Guenther To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR46288 Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 X-SW-Source: 2010-11/txt/msg00316.txt.bz2 Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2010-11-03 Richard Guenther PR middle-end/46288 * predict.c (strip_predict_hints): Simply DCE builtin expect if the result is unused. * gcc.dg/pr46288.c: New testcase. Index: gcc/predict.c =================================================================== *** gcc/predict.c (revision 166249) --- gcc/predict.c (working copy) *************** strip_predict_hints (void) *** 1329,1337 **** && gimple_call_num_args (stmt) == 2) { var = gimple_call_lhs (stmt); ! ass_stmt = gimple_build_assign (var, gimple_call_arg (stmt, 0)); ! ! gsi_replace (&bi, ass_stmt, true); } } gsi_next (&bi); --- 1329,1345 ---- && gimple_call_num_args (stmt) == 2) { var = gimple_call_lhs (stmt); ! if (var) ! { ! ass_stmt ! = gimple_build_assign (var, gimple_call_arg (stmt, 0)); ! gsi_replace (&bi, ass_stmt, true); ! } ! else ! { ! gsi_remove (&bi, true); ! continue; ! } } } gsi_next (&bi); Index: gcc/testsuite/gcc.dg/pr46288.c =================================================================== *** gcc/testsuite/gcc.dg/pr46288.c (revision 0) --- gcc/testsuite/gcc.dg/pr46288.c (revision 0) *************** *** 0 **** --- 1,8 ---- + /* { dg-do compile } */ + /* { dg-options "-O -fno-tree-dce" } */ + + void foo (int i) + { + __builtin_expect (i, i); + } +