bzero optimization rarely does

Roger Sayle roger@eyesopen.com
Sat Jul 13 10:50:00 GMT 2002


Hi Kaveh,
> In my prior email I gave you examples to follow, namely you take the
> builtin testing mechanism of string-opt-17.c and the per-chip value
> setting of gcc.dg/20020312-2.c.
>
> I went ahead and wrote it.  This testcase requires each cpu to define
> MAX appropriately, I'd expect someone testing on each platform to set
> their cpu values after I check it in.

My apologies, that's not a bad solution to the problem.

Several issues though.  The first is that the effects of -Os are target
specific, so each CPU test will need to contain its own #ifdef test
for __OPTIMIZE_SIZE__.  As I mentioned, n32k uses the value zero
independent of -Os.

The second is that the number of instructions required to clear a
block of memory depends upon its alignment, and the alignment of
the global variable "buffer" is dependent upon both the processor
and the target operating system.  Hopefully this won't be an issue.

I assume it intentional that the default case will fail on platforms
without a clrstr?i instruction, forcing them to either enter their
MAX values or add a clrstr?i instruction to their md files.

Finally, you might consider writing out "len" just before calling
abort() to allow port maintainers to determine the appropriate
MAX parameter.  Its non-trivial as the backends are parameterized
on CLEAN_RATIO, which is the number of instructions, not on the
number of bytes.  12 bytes can be written with three instructions,
but 11 bytes requires four instructions.  MAX must be the number
of bytes guaranteed to be inlined.


Sorry once again.  Although the test will only catch problems on
platforms without clrstr?i, its much better than no test at all.

Roger
--



More information about the Gcc mailing list