This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/51244] SH Target: Inefficient conditional branch
- 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: Tue, 06 Mar 2012 23:42:15 +0000
- Subject: [Bug target/51244] SH Target: Inefficient conditional branch
- Auto-submitted: auto-generated
- References: <bug-51244-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51244
--- Comment #22 from Oleg Endo <olegendo at gcc dot gnu.org> 2012-03-06 23:42:15 UTC ---
This is a reduced test case:
int test (volatile int* a, int b, int c)
{
a[1] = b != 0;
if (b == 0)
a[10] = c;
return b == 0;
}
with '-O2 -m4-single -mb' it gets compiled to:
tst r5,r5 ! b == 0 -> T
mov #-1,r1
negc r1,r1 ! b != 0 -> T, r1
mov.l r1,@(4,r4)
bf .L2 ! branch if (b == 0)
mov.l r6,@(40,r4)
.L2:
tst r5,r5
rts
movt r0
This is because in the 'movnegt' expander it is not mentioned that the T bit is
modified and the first CSE pass optimizes away the 'b == 0' test before the
branch. I'm trying to come up with some alternative approaches...