From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5154 invoked by alias); 9 Jan 2014 20:40:30 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 9397 invoked by uid 48); 9 Jan 2014 20:16:27 -0000 From: "macro@linux-mips.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/59371] [4.8/4.9 Regression] Performance regression in GCC 4.8 and later versions. Date: Thu, 09 Jan 2014 20:40:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: macro@linux-mips.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-01/txt/msg00980.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59371 --- Comment #10 from Maciej W. Rozycki --- (In reply to Jakub Jelinek from comment #9) Jakub, The fix has corrected the evaluation of `i++' however it has regressed the evaluation of `i < c'. This is because in the loop `i' is only ever assigned values that are lower than or equal to the value of `c' and here the `int' type can represent all values representable with the `signed short' and `unsigned short' types. Specifically, assuming the properties of the MIPS target, where `int' is 32-bit wide and `short' is 16-bit wide, we have the following cases of the `c' input value here: 1. 0 -- the loop is not entered because `i' is preset to 0 and equals `c' right away. 2. [1,32767] -- `i' is incremented from 0 until it reaches the value of `c', at which point the loop terminates. 3. [32768,65535] -- `i' is incremented from 0 up to 32767, at which point it wraps around to -32768 and continues being incremented to 32767 again. And so on, and so on. It never reaches the value of `c' or any higher value and therefore the loop never terminates. Based on the above observations it is enough to check for `i == c' as the loop termination condition. So I think this is still a performance regression from the user's point of view even though I realise this may not necessarily be an optimisation GCC has been previously designed for. Therefore I'd prefer to keep the bug open until/unless we decide it's impractical to implement a code transformation that would restore previous performance. Maciej