From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93039 invoked by alias); 19 Jul 2015 05:32:20 -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 92990 invoked by uid 48); 19 Jul 2015 05:32:09 -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 05:32: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: 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/msg01657.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54236 --- Comment #15 from Oleg Endo --- The following shows missed subc cases when there are constants involved. Addc cases can be constructed in the same way. int fun (int x) { return x - 1 - (x > 100); } -O2 -m4: mov #100,r1 mov r4,r0 cmp/gt r1,r4 movt r1 sett rts subc r1,r0 better: mov #100,r1 mov r4,r0 cmp/gt r1,r4 mov #1,r1 rts subc r1,r0 Combine is looking for a pattern like: (parallel [ (set (reg:SI 168 [ D.1659 ]) (plus:SI (not:SI (gt:SI (reg/v:SI 167 [ x ]) (reg:SI 172))) (reg/v:SI 167 [ x ]))) (clobber (reg:SI 147 t)) ]) constants -1 and -2 are represented as not (0) and not (1) in this case. int fun (int x) { return x - 10 - (x > 100); } -O2 -m4: mov #100,r1 mov r4,r0 cmp/gt r1,r4 add #-10,r0 mov #0,r1 rts subc r1,r0 better: mov #100,r1 mov r4,r0 cmp/gt r1,r4 mov #10,r1 rts subc r1,r0 Combine is looking for a pattern like Failed to match this instruction: (parallel [ (set (reg:SI 168 [ D.1659 ]) (plus:SI (minus:SI (reg/v:SI 167 [ x ]) (gt:SI (reg/v:SI 167 [ x ]) (reg:SI 172))) (const_int -10 [0xfffffffffffffff6]))) (clobber (reg:SI 147 t)) ]) there is already a similar pattern *subc_negreg_t