From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15856 invoked by alias); 29 Jul 2015 14:30:37 -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 15778 invoked by uid 48); 29 Jul 2015 14:30:31 -0000 From: "olegendo at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/67057] New: [SH] Use negc to calculate 1-T+const_int Date: Wed, 29 Jul 2015 14:30: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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: olegendo at gcc dot gnu.org 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone 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-07/txt/msg02556.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67057 Bug ID: 67057 Summary: [SH] Use negc to calculate 1-T+const_int Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: olegendo at gcc dot gnu.org Target Milestone: --- The following int foo (int a, int b) { return ((a & (1 << 25)) ? 5 : 4); } compiled with -O2 results in: mov.l .L4,r1 mov #-1,r0 tst r1,r4 negc r0,r0 rts add #4,r0 // r0 = 1 - T + 4 // = 5 - T .L5: .align 2 .L4: .long 33554432 The negc insn calculates 0 - reg - T, which can be used to calculate const_int + T. In fact, it is already used to calculate 1 - T as a replacement for SH2A movrt. The resulting code should look something like this: mov.l .L4,r1 mov #-5,r0 tst r1,r4 rts negc r0,r0 Combine is looking for a pattern: Failed to match this instruction: (set (reg:SI 162 [ D.1652 ]) (plus:SI (zero_extract:SI (reg:SI 4 r4 [ a ]) (const_int 1 [0x1]) (const_int 25 [0x19])) (const_int 4 [0x4]))) Which could be implemented with treg_set_expr.