[Bug target/65260] New: [SH] Convert add add sub -> sub sub sub
olegendo at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Mar 1 09:42:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65260
Bug ID: 65260
Summary: [SH] Convert add add sub -> sub sub sub
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*-*-*
I've spotted the following sequence in CSiBE bzip2/blocksort:
dmulu.l r10,r8
mov.l r8,@(8,r15)
sts mach,r0
shlr r0
mov r0,r1
add r1,r1
add r1,r0
sub r0,r8
tst r8,r8
bt/s .L253
mov r8,r0
A reduced test case is:
unsigned int test (unsigned int a, unsigned int b)
{
unsigned int x = (a * b) / 2;
unsigned int y = a - (x * 3);
return y;
}
compiled with -m4 -O2:
mul.l r5,r4
mov r4,r0
sts macl,r1
shlr r1
mov r1,r2
add r2,r2
add r2,r1
rts
sub r1,r0 // r0 = r0 - (r1 + r2 + r2)
// = r0 - r1 - r2 - r2
which can be converted to the following, saving one register:
mul.l r5,r4
mov r4,r0
sts macl,r1
shlr r1
sub r1,r0
sub r1,r0
rts
sub r1,r0
More information about the Gcc-bugs
mailing list