This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: fine-tuning for can_store_by_pieces
Richard Sandiford wrote:
Thanks for the testing. In that case, I agree 4 is fine for everything.
If you still have the results, could you post the totals? I'm curious
what kind of figures we're talking about here.
Here's what I have. Except for measuring the original version of the patch on a
mips64-elfoabi build, everything else was done with mips32r2-elfoabi; the
numbers are total sizes from CSiBE.
default -mips16 -mabicalls mips64
baseline 3583977 2860177 3558373
call ratio 3 3566997 2859401 4039960 3541493
call ratio 4 3565961 2858881 4037876
call ratio 5 3566857 2859901 4037172
call ratio 6 4037332
+ #define MIPS_CALL_RATIO 4
I think the number you use in CLEAR_RATIO (MIPS_CALL_RATIO + 2)
is effectively estimating the number of instruction for a call.
ISTM CLEAR_RATIO is basically being compared against an estimate of
the number of zero stores, and zero stores are 1 instruction on MIPS.
(Also, nothing really explained why CLEAR_RATIO adds a magic 2 to the
ratio.)
So I think this should really be 6 and that CLEAR_RATIO should be:
#define CLEAR_RATIO (optimize_size ? MIPS_CALL_RATIO : 15)
Then...
+ #define MOVE_RATIO ((TARGET_MIPS16 || TARGET_MEMCPY) ? MIPS_CALL_RATIO : 2)
...a comment in the original patch said that MOVE_RATIO effectively
counted memory-to-memory moves. I think that was a useful comment,
and that the use of the old MIPS_CALL_RATIO above should be the new
MIPS_CALL_RATIO / 2. Conveniently, that gives us the 3 that you had
in the original patch.
Except that 4 seems to be a better number, and that number doesn't fall out of
this theory. I guess I could run some tests with different values for
CLEAR_RATIO too, and just document both numbers as being experimentally determined?
(You didn't say whether you'd benchmarked
-mips16 or -mmemcpy; if so, did you see any difference between a
MOVE_RATIO of 3 and a MOVE_RATIO of 4?)
I tried -mips16 but not -mmemcpy. See table above.
+ /* STORE_BY_PIECES_P can be used when copying a constant string, but
+ in that case each word takes 3 insns (lui, ori, sw), or more in
+ 64-bit mode, instead of 2 (lw, sw). So better to always fail this
+ and let the move_by_pieces code copy the string from read-only
+ memory. */
+
+ #define STORE_BY_PIECES_P(SIZE, ALIGN) 0
You asked when lui/ori/sw might be faster. Consider a three-word
store on a typical 2-way superscalar target:
Cycle 1: lui lui
2: ori ori
3: sw lui
4: sw ori
5: sw
That's 5 cycles. The equivalent lw/sw version is at least 6 cycles
(more if the read-only string is not in cache).
OK, but what I was really asking was, is there a way to *test* for situations
where we should generate the lui/ori/sw sequences instead of the lw/sw? Some
combination of TARGET_foo flags and/or the size of the string?
-Sandra the clueless