From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28261 invoked by alias); 22 Feb 2015 16:10:05 -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 28224 invoked by uid 48); 22 Feb 2015 16:10:02 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/65164] New: [5 Regression][SH] missed subc in integer sign function Date: Sun, 22 Feb 2015 16:51:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: olegendo at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cf_gcctarget Message-ID: 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-02/txt/msg02436.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65164 Bug ID: 65164 Summary: [5 Regression][SH] missed subc in integer sign function Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: olegendo at gcc dot gnu.org Target: sh*-*-* These are integer sign functions taken from a book. For some of them the code got worse after the introduction of the treg_set_expr stuff. int signfunc_00 (int x) { return (x >> 31) | ((unsigned int)(-x) >> 31); } int signfunc_01 (int x) { return -((unsigned int)x >> 31) | ((unsigned int)(-x) >> 31); } int signfunc_02 (int x) { return (x > 0) - (x < 0); } 4.9: cmp/pl r4 movt r0 shll r4 movt r4 rts sub r4,r0 trunk: mov r4,r1 shll r1 movt r1 cmp/pl r4 movt r0 rts sub r1,r0 int signfunc_03 (int x) { return (x >= 0) - (x <= 0); } 4.9: cmp/pz r4 mov #0,r1 movt r0 cmp/ge r4,r1 rts subc r1,r0 trunk: mov #0,r1 cmp/ge r4,r1 movt r1 cmp/pz r4 movt r0 rts sub r1,r0 It seems that this requires a pattern like (set (match_operand:SI 0 "arith_reg_dest") (minus:SI (match_operand 1 "treg_set_expr") (match_operand 2 "treg_set_expr"))) For signfunc_02, combine is looking for the pattern: Failed to match this instruction: (set (reg:SI 169 [ D.1518 ]) (minus:SI (gt:SI (reg/v:SI 168 [ x ]) (const_int 0 [0])) (lshiftrt:SI (reg/v:SI 168 [ x ]) (const_int 31 [0x1f])))) For signfunc_03, combine is looking for the pattern: (set (reg:SI 169 [ D.1522 ]) (minus:SI (ge:SI (reg:SI 4 r4 [ x ]) (const_int 0 [0])) (le:SI (reg:SI 4 r4 [ x ]) (const_int 0 [0])))) On SH, it seems that the insn sequence cmp/pz r4 mov #0,r1 movt r0 cmp/ge r4,r1 subc r1,r0 is the best to realize an integer sign function. So actually all the functions above should be converted into the same sequence.