From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99889 invoked by alias); 19 Jul 2015 06:47:56 -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 99827 invoked by uid 48); 19 Jul 2015 06:47:48 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/54236] [SH] Improve addc and subc insn utilization Date: Sun, 19 Jul 2015 06:47: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.8.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: olegendo at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created 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-07/txt/msg01658.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54236 --- Comment #16 from Oleg Endo --- Created attachment 36012 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36012&action=edit addsicc pattern (In reply to Oleg Endo from comment #9) > The following function compiled with -O2 > > unsigned int check (unsigned int x) > { > return x == 0 ? 1 : x; > } > > results in: > tst r4,r4 > bt/s .L7 > mov #1,r0 > mov r4,r0 > .L7: > rts > nop > > > Writing it as: > unsigned int check (unsigned int x) > { > return x + (x == 0); > } > > results in: > tst r4,r4 > mov #0,r0 > rts > addc r4,r0 > > It seems that ifcvt is trying to utilize the 'addcc' standard name > pattern. If the 2nd operand of the conditional addition is a constant 1 or > -1 the addcc insn can be implemented via addc or subc without a branch. The attached patch adds support for the addsicc pattern and a few other improvements. However, the first case above doesn't see any improvement. It seems that it's a missed ifcvt optimization.