From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79492 invoked by alias); 12 May 2015 09:58:41 -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 75344 invoked by uid 48); 12 May 2015 09:58:33 -0000 From: "ysrumyan at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/64691] Suboptimal register allocation for bytes comparison on i386 Date: Tue, 12 May 2015 09:58: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: 5.0 X-Bugzilla-Keywords: missed-optimization, ra X-Bugzilla-Severity: normal X-Bugzilla-Who: ysrumyan at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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-05/txt/msg00920.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64691 Yuri Rumyantsev changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ysrumyan at gmail dot com --- Comment #1 from Yuri Rumyantsev --- I found another register allocation deficiency which can be exhibited at the attached test-case extracted from important benchmark. If we look at inner loop for(i = 0; i < size; i++) { byte xr, xg, xb, t1; sbyte t2, t3; x1 = read[0]; x2 = read[1]; x3 = read[2]; t1 = (byte) (((C1 * x1) + (C2 * x2) + (C3 * x3) + (1 << (SCALE - 1))) >> SCALE); t2 = (sbyte) (((C4 * x1) + (C5 * x2) + (C6 * x3) + (1 << (SCALE - 1))) >> SCALE); t3 = (sbyte) (((C7 * x1) + (C8 * x2) + (C9 * x3) + (1 << (SCALE - 1))) >> SCALE); write[0] = t1; write[1] = (byte) t2; write[2] = (byte) t3; read += 3; write += 3; } we can see that 7 registers is enough to keep all variable (except for upper loop bound): 3 registers for x1,x2,x3, 2 registers for read and write pointers and 2 registers for computation one for t1,t2,t3 computations and one scratch register for multiplications (but since consumers of t1,t2,t3 is byte store this register must belong also to Q_REQS subset, i.e. AREG,BREG,CREG or DREG). But LRA does not perform such allocation and this leads to redundant spill/fills and results in performance degradation. Assembly file produced 6.0 compiler with "-O2 -m32 -march=slm" options is attached too.