public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105311] New: [12]Still generate memset even with -fno-tree-loop-distribute-patterns
@ 2022-04-19 16:05 570070308 at qq dot com
  2022-04-19 16:21 ` [Bug c/105311] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: 570070308 at qq dot com @ 2022-04-19 16:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105311

            Bug ID: 105311
           Summary: [12]Still generate memset even with
                    -fno-tree-loop-distribute-patterns
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 570070308 at qq dot com
  Target Milestone: ---

I have read the https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888 , according
to this, adding `-fno-tree-loop-distribute-patterns` will prevent gcc from
calling memset. However, the gcc still call memset with the code below:
```test.c
#include <stdint.h>
struct Page_Table_Page
{
    uint64_t pts[511][512];
};

void init_ptp(struct Page_Table_Page*const ptp)
{
    *ptp=(struct Page_Table_Page){{{0}}};
}
```
compile with:
```
gcc-12 -O3 test.c -S -fno-tree-loop-distribute-patterns -fno-builtin-memset
-fno-builtin -nodefaultlibs -nostdlib -ffreestanding
```

```test.s
init_ptp:
.LFB24:
        .cfi_startproc
        endbr64
        subq    $8, %rsp
        .cfi_def_cfa_offset 16
        movl    $2093056, %edx
        xorl    %esi, %esi
        call    memset@PLT
        addq    $8, %rsp
        .cfi_def_cfa_offset 8
        ret
```

The gcc-12 is installed by apt on Ubuntu 22.04.
The full compile log:
```
$ gcc-12 -O3 test.c -S -fno-tree-loop-distribute-patterns -fno-builtin-memset
-fno-builtin -nodefaultlibs -nostdlib -ffreestanding -v
Using built-in specs.
COLLECT_GCC=gcc-12
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
12-20220319-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-12
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-12-OcsLtf/gcc-12-12-20220319/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-OcsLtf/gcc-12-12-20220319/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.1 20220319 (experimental) [master r12-7719-g8ca61ad148f]
(Ubuntu 12-20220319-1ubuntu1) 
COLLECT_GCC_OPTIONS='-O3' '-S' '-fno-tree-loop-distribute-patterns'
'-fno-builtin-memset' '-fno-builtin' '-nodefaultlibs' '-nostdlib'
'-ffreestanding' '-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/12/cc1 -quiet -v -imultiarch x86_64-linux-gnu
test.c -quiet -dumpbase test.c -dumpbase-ext .c -mtune=generic -march=x86-64
-O3 -version -fno-tree-loop-distribute-patterns -fno-builtin-memset
-fno-builtin -ffreestanding -o test.s -fasynchronous-unwind-tables -Wformat
-Wformat-security -fstack-clash-protection -fcf-protection
GNU C17 (Ubuntu 12-20220319-1ubuntu1) version 12.0.1 20220319 (experimental)
[master r12-7719-g8ca61ad148f] (x86_64-linux-gnu)
        compiled by GNU C version 12.0.1 20220319 (experimental) [master
r12-7719-g8ca61ad148f], GMP version 6.2.1, MPFR version 4.1.0, MPC version
1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/12/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/12/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C17 (Ubuntu 12-20220319-1ubuntu1) version 12.0.1 20220319 (experimental)
[master r12-7719-g8ca61ad148f] (x86_64-linux-gnu)
        compiled by GNU C version 12.0.1 20220319 (experimental) [master
r12-7719-g8ca61ad148f], GMP version 6.2.1, MPFR version 4.1.0, MPC version
1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 200a3dd46f0674d1a8fcf2b133bc6014
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/12/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/12/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-O3' '-S' '-fno-tree-loop-distribute-patterns'
'-fno-builtin-memset' '-fno-builtin' '-nodefaultlibs' '-nostdlib'
'-ffreestanding' '-v' '-mtune=generic' '-march=x86-64'
```

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/105311] [12]Still generate memset even with -fno-tree-loop-distribute-patterns
  2022-04-19 16:05 [Bug c/105311] New: [12]Still generate memset even with -fno-tree-loop-distribute-patterns 570070308 at qq dot com
@ 2022-04-19 16:21 ` pinskia at gcc dot gnu.org
  2022-04-20  7:26 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-04-19 16:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105311

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
No member can be emitted for other reasons. This is a dup of a much much older
issue. Memset for this case has been emitting since at least 3.0.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/105311] [12]Still generate memset even with -fno-tree-loop-distribute-patterns
  2022-04-19 16:05 [Bug c/105311] New: [12]Still generate memset even with -fno-tree-loop-distribute-patterns 570070308 at qq dot com
  2022-04-19 16:21 ` [Bug c/105311] " pinskia at gcc dot gnu.org
@ 2022-04-20  7:26 ` rguenth at gcc dot gnu.org
  2022-04-20 11:49 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-20  7:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105311

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jsm28 at gcc dot gnu.org
           Keywords|                            |documentation

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
All memcpy, memmove and memset are eventually emitted for aggregate copying and
initialization.  Targets may choose to force inline them but there is indeed no
libgcc fallback with -ffreestanding.

Our -ffreestanding documentation ought to reflect this I guess.  Joseph, do you
know of other library routines GCC requires but does not provide even with
-ffreestanding?  There might or might not be a subset of the C standard library
that is supposed to be available in a freestanding implementation - like good
parts of the math runtime, and GCC likely doesn't diagnose usage with
-ffreestanding but assumes the user provides the necessary implementations via
custom libraries.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/105311] [12]Still generate memset even with -fno-tree-loop-distribute-patterns
  2022-04-19 16:05 [Bug c/105311] New: [12]Still generate memset even with -fno-tree-loop-distribute-patterns 570070308 at qq dot com
  2022-04-19 16:21 ` [Bug c/105311] " pinskia at gcc dot gnu.org
  2022-04-20  7:26 ` rguenth at gcc dot gnu.org
@ 2022-04-20 11:49 ` jakub at gcc dot gnu.org
  2022-04-20 12:07 ` rguenth at gcc dot gnu.org
  2022-04-20 12:26 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-20 11:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105311

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think we document this:
https://gcc.gnu.org/onlinedocs/gcc/Standards.html#index-ffreestanding

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/105311] [12]Still generate memset even with -fno-tree-loop-distribute-patterns
  2022-04-19 16:05 [Bug c/105311] New: [12]Still generate memset even with -fno-tree-loop-distribute-patterns 570070308 at qq dot com
                   ` (2 preceding siblings ...)
  2022-04-20 11:49 ` jakub at gcc dot gnu.org
@ 2022-04-20 12:07 ` rguenth at gcc dot gnu.org
  2022-04-20 12:26 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-04-20 12:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105311

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #3)
> I think we document this:
> https://gcc.gnu.org/onlinedocs/gcc/Standards.html#index-ffreestanding

Ah yes, I was only looking at the -ffreestanding documentation.

So I'd say INVALID.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/105311] [12]Still generate memset even with -fno-tree-loop-distribute-patterns
  2022-04-19 16:05 [Bug c/105311] New: [12]Still generate memset even with -fno-tree-loop-distribute-patterns 570070308 at qq dot com
                   ` (3 preceding siblings ...)
  2022-04-20 12:07 ` rguenth at gcc dot gnu.org
@ 2022-04-20 12:26 ` jakub at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-04-20 12:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105311

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And that documentation links to that section:
https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#index-ffreestanding-1

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-04-20 12:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19 16:05 [Bug c/105311] New: [12]Still generate memset even with -fno-tree-loop-distribute-patterns 570070308 at qq dot com
2022-04-19 16:21 ` [Bug c/105311] " pinskia at gcc dot gnu.org
2022-04-20  7:26 ` rguenth at gcc dot gnu.org
2022-04-20 11:49 ` jakub at gcc dot gnu.org
2022-04-20 12:07 ` rguenth at gcc dot gnu.org
2022-04-20 12:26 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).