[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 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 c/90435] New: 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

Bug ID: 90435
   Summary: gcc generate infinite loop code when using -O2 or -O3
   Product: gcc
   Version: 8.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: pangqingyuan1991 at 163 dot com
  Target Milestone: ---

Created attachment 46342
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46342=edit
source code

I am writing a simple memory allocator now. When I compile it with -O0 or -O1,
it works as expected. But when I use -O2 or -O3. The example code seems run
into dead loop and never finish. 
Also try gcc-6.5.0 gcc-7.4.0 gcc-9.1.0 . Since that all gcc versions have such
problem.
But clang-6 and clang-8 work well as expected.


Compiling: gcc pmalloc.c -O2 -o ppp -ldl
Running: PMALLOC_SIZE=128M ./ppp