m68k: Simple loop compiles into boundless recursion with -O2

Alexander Monakov amonakov@ispras.ru
Thu Jan 14 15:09:48 GMT 2021


On Thu, 14 Jan 2021, Alexander Monakov via Gcc-help wrote:

> On Thu, 14 Jan 2021, Fredrik Noring wrote:
> 
> > > __attribute__((optimize("no-tree-loop-distribute-patterns"))) 
> > > void *memset2(void *s, int c, unsigned int n)
> > > {
> > > ...
> > 
> > This works, too, and I prefer it because the __attribute__ is attached
> > to the code itself.
> 
> Just keep in mind that this attribute is currently not intended for use
> apart from debugging/testing:
> 
> https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-optimize-function-attribute
> 
>   The optimize attribute should be used for debugging purposes only. It is not
>   suitable in production code.

(part of the reason for that being that the interaction of the attribute with
options passed on the command line is poorly defined: currently adding the
attribute results in other -O and -f options dropped for the function, IIRC;
this should have gone out with the previous email, sorry about sending that
prematurely)

> Alexander
> 


More information about the Gcc-help mailing list