This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/54236] [SH] Improve addc and subc insn utilization
- From: "olegendo at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 19 Jul 2015 05:32:04 +0000
- Subject: [Bug target/54236] [SH] Improve addc and subc insn utilization
- Auto-submitted: auto-generated
- References: <bug-54236-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54236
--- Comment #15 from Oleg Endo <olegendo at gcc dot gnu.org> ---
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