From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11650 invoked by alias); 29 Jan 2015 02:03:39 -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 29875 invoked by uid 48); 29 Jan 2015 02:03:29 -0000 From: "bruck.michael at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/64774] [ARM/thumb] missed optimization: pc relative ldr used when constant can be derived from register Date: Thu, 29 Jan 2015 02:03: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.3 X-Bugzilla-Keywords: X-Bugzilla-Severity: minor X-Bugzilla-Who: bruck.michael at googlemail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P5 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: 2015-01/txt/msg03338.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64774 --- Comment #2 from Michael Bruck --- (In reply to Richard Earnshaw from comment #1) > Although the compiler tries to find some common cases, it is generally > infeasible to detect all the possible permutations that exist. Furthermore, > in real code generating common expressions in this way can increase register > pressure and have additional impact on some optimization passes. > > I don't hold out much hope of this sort of problem ever being entirely fixed. I wonder if the logic that recognizes cases 1-3 could be expanded to work with the rest too. It almost looks to me as if there is a bug that checks the size of the constant and not the difference to decide what can be substituted with an addition. The register pressure issue could be avoided if the optimization is applied later and only for cases where the value already happens to be in a register.