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 22:43:11 +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 #3 from Oleg Endo <oleg.endo@t-online.de> 2011-12-27 22:43:11 UTC ---
Created attachment 26191
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26191
Proposed patch to improve some of the issues.
(In reply to comment #1)
>
> [...]
>
> mov #-1,rn
> negc rn,rm
> tst #255,rm
>
> which is essentially T_reg = T_reg. Usually combine catches such
> situation, but negc might be too complex for combine.
> For this case, replacing current movnegt expander by insn, splitter
> and peephole something like
>
> [...]
>
> the above useless sequence could be removed, though we will miss
> the chance that the -1 can be CSE-ed when the cstore value is
> used. This will cause a bit worse code for the loop like
>
> int
> foo (int *a, int x, int n)
> {
> int i;
> int count;
>
> for (i = 0; i < n; i++)
> count += (*(a + i) != x);
>
> return count;
> }
>
Thanks for your ideas and comments. It was really useful.
The attached patch removes the useless sequence and still allows the -1
constant to be CSE-ed for such cases as the example function above.
I haven't ran all tests on it yet, but CSiBE shows average code size reduction
of approx. -0.1% for -m4* with some code size increases in some files.
Would something like that be OK for stage 3?