From patchwork Wed Sep 7 01:32:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Schmidt X-Patchwork-Id: 113685 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 E9275B6F69 for ; Wed, 7 Sep 2011 11:35:14 +1000 (EST) Received: (qmail 2877 invoked by alias); 7 Sep 2011 01:35:11 -0000 Received: (qmail 2712 invoked by uid 22791); 7 Sep 2011 01:35:09 -0000 X-SWARE-Spam-Status: No, hits=1.7 required=5.0 tests=AWL, BAYES_00, BOTNET, FROM_12LTRDOM, RDNS_NONE, TW_CF X-Spam-Check-By: sourceware.org Received: from Unknown (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 07 Sep 2011 01:34:53 +0000 Received: (qmail 21879 invoked from network); 7 Sep 2011 01:34:52 -0000 Received: from unknown (HELO ?84.152.197.52?) (bernds@127.0.0.2) by mail.codesourcery.com with ESMTPA; 7 Sep 2011 01:34:52 -0000 Message-ID: <4E66C9C2.4000300@codesourcery.com> Date: Wed, 07 Sep 2011 03:32:50 +0200 From: Bernd Schmidt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.20) Gecko/20110905 Lightning/1.0b3pre Thunderbird/3.1.12 MIME-Version: 1.0 To: GCC Patches Subject: Fix a cfgcleanup head-merge issue on cc0 targets 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 This showed up with a coldfire-linux toolchain. get_condition can return NULL in some cases when the condition is reversed and there are float modes involved; in that case we will move instructions in between a cc0 user and setter. This patch fixes it. Tested on cris-elf, since I currently have no way of testing m68k. Will commit as obvious tomorrow if no objections. Bernd * cfgcleanup.c (try_head_merge_bb): If get_condition returns NULL for a jump that is a cc0 insn, pick the previous insn for move_before. * gcc.c-torture/compile/20110907.c: New file. Index: gcc/cfgcleanup.c =================================================================== --- gcc/cfgcleanup.c (revision 178596) +++ gcc/cfgcleanup.c (working copy) @@ -2214,7 +2214,14 @@ try_head_merge_bb (basic_block bb) cond = get_condition (jump, &move_before, true, false); if (cond == NULL_RTX) - move_before = jump; + { +#ifdef HAVE_cc0 + if (reg_mentioned_p (cc0_rtx, jump)) + move_before = prev_nonnote_nondebug_insn (jump); + else +#endif + move_before = jump; + } for (ix = 0; ix < nedges; ix++) if (EDGE_SUCC (bb, ix)->dest == EXIT_BLOCK_PTR) @@ -2376,7 +2383,14 @@ try_head_merge_bb (basic_block bb) jump = BB_END (final_dest_bb); cond = get_condition (jump, &move_before, true, false); if (cond == NULL_RTX) - move_before = jump; + { +#ifdef HAVE_cc0 + if (reg_mentioned_p (cc0_rtx, jump)) + move_before = prev_nonnote_nondebug_insn (jump); + else +#endif + move_before = jump; + } } do Index: gcc/testsuite/gcc.c-torture/compile/20110907.c =================================================================== --- gcc/testsuite/gcc.c-torture/compile/20110907.c (revision 0) +++ gcc/testsuite/gcc.c-torture/compile/20110907.c (revision 0) @@ -0,0 +1,26 @@ +struct ieee754_double { + double d; +}; +extern const float __exp_deltatable[178]; +float __ieee754_expf (float x) +{ + static const float himark = 88.72283935546875; + static const float lomark = -103.972084045410; + if (__builtin_isless(x, himark) && __builtin_isgreater(x, lomark)) + { + int tval; + double x22, t, result, dx; + float delta; + struct ieee754_double ex2_u; + dx -= t; + tval = (int) (t * 512.0); + if (t >= 0) + delta = - __exp_deltatable[tval]; + else + delta = __exp_deltatable[-tval]; + x22 = (0.5000000496709180453 * dx + 1.0000001192102037084) * dx + delta; + result = x22 * ex2_u.d + ex2_u.d; + return (float) result; + } + return x; +}