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.