[Bug middle-end/90435] gcc generate infinite loop code when using -O2 or -O3

2019-05-12 Thread sch...@linux-m68k.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90435

Andreas Schwab  changed:

   What|Removed |Added

 Resolution|FIXED   |INVALID

[Bug middle-end/90435] gcc generate infinite loop code when using -O2 or -O3

2019-05-12 Thread pangqingyuan1991 at 163 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90435

庞庆源  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from 庞庆源  ---
Fixed

[Bug middle-end/90435] gcc generate infinite loop code when using -O2 or -O3

2019-05-12 Thread pangqingyuan1991 at 163 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90435

--- Comment #4 from 庞庆源  ---
(In reply to Marc Glisse from comment #3)
> (In reply to 庞庆源 from comment #2)
> > gcc pmalloc.c -O2 -o ppp -ldl  -fno-tree-loop-distribute-patterns
> > -fno-strict-aliasing
> > Still not work.
> 
> -fno-builtin (the malloc+memset -> calloc is not part of loop distribution)
> 
> > Why I don't see stack overflow if this will trigger function loop calling
> 
> tail call?

-fno-builtin is the solution, thanks!

[Bug middle-end/90435] gcc generate infinite loop code when using -O2 or -O3

2019-05-11 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90435

--- Comment #3 from Marc Glisse  ---
(In reply to 庞庆源 from comment #2)
> gcc pmalloc.c -O2 -o ppp -ldl  -fno-tree-loop-distribute-patterns
> -fno-strict-aliasing
> Still not work.

-fno-builtin (the malloc+memset -> calloc is not part of loop distribution)

> Why I don't see stack overflow if this will trigger function loop calling

tail call?

[Bug middle-end/90435] gcc generate infinite loop code when using -O2 or -O3

2019-05-11 Thread pangqingyuan1991 at 163 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90435

--- Comment #2 from 庞庆源  ---
gcc pmalloc.c -O2 -o ppp -ldl  -fno-tree-loop-distribute-patterns
-fno-strict-aliasing
Still not work.

Why I don't see stack overflow if this will trigger function loop calling

[Bug middle-end/90435] gcc generate infinite loop code when using -O2 or -O3

2019-05-11 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90435

--- Comment #1 from Andrew Pinski  ---
Your implementation of calloc will be calling itself due to the optimization of
malloc followed by memset into calloc.

You need to use -fno-tree-loop-distribute-patterns for that case  since your
implementation of malloc calls calloc in some cases.

One other thing is you are most likely also violating C aliasing rules; try
-fno-strict-aliasing and see if that helps.