From patchwork Mon Dec 19 20:29:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 132310 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 BAE09B6FEC for ; Tue, 20 Dec 2011 07:32:09 +1100 (EST) Received: (qmail 3120 invoked by alias); 19 Dec 2011 20:32:06 -0000 Received: (qmail 3111 invoked by uid 22791); 19 Dec 2011 20:32:05 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Dec 2011 20:31:53 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1RcjsF-0006kI-BZ from Sandra_Loosemore@mentor.com ; Mon, 19 Dec 2011 12:31:51 -0800 Received: from SVR-ORW-FEM-04.mgc.mentorg.com ([147.34.97.41]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 19 Dec 2011 12:31:51 -0800 Received: from [IPv6:::1] (147.34.91.1) by svr-orw-fem-04.mgc.mentorg.com (147.34.97.41) with Microsoft SMTP Server id 14.1.289.1; Mon, 19 Dec 2011 12:31:50 -0800 Message-ID: <4EEF9EC3.8070807@codesourcery.com> Date: Mon, 19 Dec 2011 13:29:55 -0700 From: Sandra Loosemore User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: Eric Botcazou CC: Subject: Re: PATCH: fix infinite loop in CSE References: <4EE6BE29.9020005@codesourcery.com> <201112181321.39315.ebotcazou@adacore.com> In-Reply-To: <201112181321.39315.ebotcazou@adacore.com> 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 On 12/18/2011 05:21 AM, Eric Botcazou wrote: > > OK everywhere without the cap and with the same test on ARG2: > If a testcase doesn't need fancy options, it must go in gcc.c-torture/compile. OK. I've checked in this version, which addresses both those issues. -Sandra 2011-12-19 Sandra Loosemore Tom de Vries PR rtl-opt/50380 gcc/ * cse.c (find_comparison_args): Detect fixed point and bail early. gcc/testsuite/ * gcc.c-torture/compile/pr50380.c: New testcase. Index: gcc/testsuite/gcc.c-torture/compile/pr50380.c =================================================================== --- gcc/testsuite/gcc.c-torture/compile/pr50380.c (revision 0) +++ gcc/testsuite/gcc.c-torture/compile/pr50380.c (revision 0) @@ -0,0 +1,12 @@ +/* This test used to get stuck in an infinite loop in find_comparison_args + when compiling for MIPS at -O2. */ + +__attribute__ ((__noreturn__)) extern void fail (void); + +char x; + +void foo (const unsigned char y) +{ + ((void) (__builtin_expect((!! y == y), 1) ? 0 : (fail (), 0))); + x = ! y; +} Index: gcc/cse.c =================================================================== --- gcc/cse.c (revision 181994) +++ gcc/cse.c (working copy) @@ -3055,6 +3055,12 @@ find_comparison_args (enum rtx_code code if (! exp_equiv_p (p->exp, p->exp, 1, false)) continue; + /* If it's the same comparison we're already looking at, skip it. */ + if (COMPARISON_P (p->exp) + && XEXP (p->exp, 0) == arg1 + && XEXP (p->exp, 1) == arg2) + continue; + if (GET_CODE (p->exp) == COMPARE /* Another possibility is that this machine has a compare insn that includes the comparison code. In that case, ARG1 would