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: "oleg dot endo at t-online dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 27 Dec 2011 21:26:33 +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 #2 from Oleg Endo <oleg.endo@t-online.de> 2011-12-27 21:26:33 UTC ---
(In reply to comment #1)
>
> BTW, OT, (a != b || a != c) ? b : c could be reduced to b, I think.
>
Yes, very much so.
It is reduced to "return b" for -m2, -m2e, -m2a, -m3, -m3e
but not for -m1 and -m4*.
The correct test function should be rather:
int test_func_0_NG (int a, int b, int c, int d)
{
return (a != b || a != d) ? b : c;
}
which is actually OK for all variants except -m1 and -m4*:
cmp/eq r5,r4 ! 11 cmpeqsi_t/3 [length = 2]
bf.s .L6 ! 12 branch_false [length = 2]
cmp/eq r7,r5 ! 14 cmpeqsi_t/3 [length = 2]
bf .L6 ! 15 branch_false [length = 2]
mov r6,r5 ! 8 movsi_i/2 [length = 2]
.L6:
rts ! 42 *return_i [length = 2]
mov r5,r0 ! 23 movsi_i/2 [length = 2]