public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/59420] New: arm: broken code generated (memset from newlib 2.0)
@ 2013-12-07 23:31 holler at ahsoftware dot de
  2013-12-07 23:32 ` [Bug c/59420] " holler at ahsoftware dot de
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: holler at ahsoftware dot de @ 2013-12-07 23:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59420

            Bug ID: 59420
           Summary: arm: broken code generated (memset from newlib 2.0)
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: holler at ahsoftware dot de

Created attachment 31396
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31396&action=edit
memset.i

Using gcc (4.8.2) to compile newlib 2.0 broken code will be generated for
memset.

Target was an ARM cortex-m3.

I believe that happens for 4.7.3 too, but I'm totally sure if I'm not just had
another bug with 4.7.3 (would have to verify it).

Compiler was cross-gcc build on Gentoo with crossdev.

gcc -v:

Target: arm-cortexm3-eabi
Configured with:
/var/tmp/portage/cross-arm-cortexm3-eabi/gcc-4.8.2/work/gcc-4.8.2/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/arm-cortexm3-eabi/gcc-bin/4.8.2
--includedir=/usr/lib/gcc/arm-cortexm3-eabi/4.8.2/include
--datadir=/usr/share/gcc-data/arm-cortexm3-eabi/4.8.2
--mandir=/usr/share/gcc-data/arm-cortexm3-eabi/4.8.2/man
--infodir=/usr/share/gcc-data/arm-cortexm3-eabi/4.8.2/info
--with-gxx-include-dir=/usr/lib/gcc/arm-cortexm3-eabi/4.8.2/include/g++-v4
--host=x86_64-pc-linux-gnu --target=arm-cortexm3-eabi
--build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point
--without-cloog --disable-lto --disable-nls --with-system-zlib
--enable-obsolete --disable-werror --enable-secureplt --disable-multilib
--disable-libmudflap --disable-libssp --disable-libgomp
--with-python-dir=/share/gcc-data/arm-cortexm3-eabi/4.8.2/python
--enable-poison-system-directories --enable-checking=release --disable-libgcj
--enable-libstdcxx-time --disable-libquadmath --enable-languages=c,c++
--with-sysroot=/usr/arm-cortexm3-eabi --disable-bootstrap --with-newlib
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.8.2 p1.0,
pie-0.5.8' --with-mode=thumb --with-cpu=cortex-m3 --with-float=soft
Thread model: single
gcc version 4.8.2 (Gentoo 4.8.2 p1.0, pie-0.5.8) 


The broken code was compiled with:

make[5]: Entering directory
`/var/tmp/portage/cross-arm-cortexm3-eabi/newlib-2.0.0/work/build/arm-cortexm3-eabi/newlib/libc/string'
arm-cortexm3-eabi-gcc
-B/var/tmp/portage/cross-arm-cortexm3-eabi/newlib-2.0.0/work/build/arm-cortexm3-eabi/newlib/
-isystem
/var/tmp/portage/cross-arm-cortexm3-eabi/newlib-2.0.0/work/build/arm-cortexm3-eabi/newlib/targ-include
-isystem
/var/tmp/portage/cross-arm-cortexm3-eabi/newlib-2.0.0/work/newlib-2.0.0/newlib/libc/include
-B/var/tmp/portage/cross-arm-cortexm3-eabi/newlib-2.0.0/work/build/arm-cortexm3-eabi/libgloss/arm
-L/var/tmp/portage/cross-arm-cortexm3-eabi/newlib-2.0.0/work/build/arm-cortexm3-eabi/libgloss/libnosys
-L/var/tmp/portage/cross-arm-cortexm3-eabi/newlib-2.0.0/work/newlib-2.0.0/libgloss/arm
   -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\"
-DPACKAGE_VERSION=\"2.0.0\" -DPACKAGE_STRING=\"newlib\ 2.0.0\"
-DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I.
-I/var/tmp/portage/cross-arm-cortexm3-eabi/newlib-2.0.0/work/newlib-2.0.0/newlib/libc/string
-D__SINGLE_THREAD__ -DARM_RDI_MONITOR -fno-builtin      -g -O2 -O3 -pipe
-fomit-frame-pointer -std=gnu99 -save-temps -c -o lib_a-memset.o `test -f
'memset.c' || echo
'/var/tmp/portage/cross-arm-cortexm3-eabi/newlib-2.0.0/work/newlib-2.0.0/newlib/libc/string/'`memset.c

If more information is necessary or helpful, please just notify me.


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

* [Bug c/59420] arm: broken code generated (memset from newlib 2.0)
  2013-12-07 23:31 [Bug c/59420] New: arm: broken code generated (memset from newlib 2.0) holler at ahsoftware dot de
@ 2013-12-07 23:32 ` holler at ahsoftware dot de
  2013-12-08  0:30 ` rearnsha at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: holler at ahsoftware dot de @ 2013-12-07 23:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59420

--- Comment #1 from Alexander Holler <holler at ahsoftware dot de> ---
Created attachment 31397
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31397&action=edit
memset.s


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

* [Bug c/59420] arm: broken code generated (memset from newlib 2.0)
  2013-12-07 23:31 [Bug c/59420] New: arm: broken code generated (memset from newlib 2.0) holler at ahsoftware dot de
  2013-12-07 23:32 ` [Bug c/59420] " holler at ahsoftware dot de
@ 2013-12-08  0:30 ` rearnsha at gcc dot gnu.org
  2013-12-08  0:56 ` [Bug middle-end/59420] " pinskia at gcc dot gnu.org
  2013-12-08  2:29 ` holler at ahsoftware dot de
  3 siblings, 0 replies; 5+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2013-12-08  0:30 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59420

--- Comment #2 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
You'll get more attention paid to this if you can describe why you think the
code generated is incorrect.


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

* [Bug middle-end/59420] arm: broken code generated (memset from newlib 2.0)
  2013-12-07 23:31 [Bug c/59420] New: arm: broken code generated (memset from newlib 2.0) holler at ahsoftware dot de
  2013-12-07 23:32 ` [Bug c/59420] " holler at ahsoftware dot de
  2013-12-08  0:30 ` rearnsha at gcc dot gnu.org
@ 2013-12-08  0:56 ` pinskia at gcc dot gnu.org
  2013-12-08  2:29 ` holler at ahsoftware dot de
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-12-08  0:56 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59420

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
          Component|c                           |middle-end
         Resolution|---                         |INVALID

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Earnshaw from comment #2)
> You'll get more attention paid to this if you can describe why you think the
> code generated is incorrect.

The issue is there is a loop inside of memset that gets converted to a call to
memset; that is if I read the assembly code correctly.  if that is the case
then this is a bug in the newlib makefiles as they should be using
-fno-tree-loop-distribute-patterns or like what glibc does:
/* Add the compiler optimization to inhibit loop transformation to library
   calls.  This is used to avoid recursive calls in memset and memmove
   default implementations.  */
#ifdef HAVE_CC_INHIBIT_LOOP_TO_LIBCALL
# define inhibit_loop_to_libcall \
    __attribute__ ((__optimize__ ("-fno-tree-loop-distribute-patterns")))
#else
# define inhibit_loop_to_libcall
#endif

So closing as invalid, please report this to newlib.

Note the work around is not to use -O3 or use -O3
-fno-tree-loop-distribute-patterns .


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

* [Bug middle-end/59420] arm: broken code generated (memset from newlib 2.0)
  2013-12-07 23:31 [Bug c/59420] New: arm: broken code generated (memset from newlib 2.0) holler at ahsoftware dot de
                   ` (2 preceding siblings ...)
  2013-12-08  0:56 ` [Bug middle-end/59420] " pinskia at gcc dot gnu.org
@ 2013-12-08  2:29 ` holler at ahsoftware dot de
  3 siblings, 0 replies; 5+ messages in thread
From: holler at ahsoftware dot de @ 2013-12-08  2:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59420

--- Comment #4 from Alexander Holler <holler at ahsoftware dot de> ---
Thanks a lot for the very fast solution.

I wasn't aware that gcc does such optimizations and maybe posted the bug too
fast without really having examined the assembler.

Using -fno-tree-loop-distribute-patterns indeed fixes the problem.

Again, thanks a lot.


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

end of thread, other threads:[~2013-12-08  2:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-07 23:31 [Bug c/59420] New: arm: broken code generated (memset from newlib 2.0) holler at ahsoftware dot de
2013-12-07 23:32 ` [Bug c/59420] " holler at ahsoftware dot de
2013-12-08  0:30 ` rearnsha at gcc dot gnu.org
2013-12-08  0:56 ` [Bug middle-end/59420] " pinskia at gcc dot gnu.org
2013-12-08  2:29 ` holler at ahsoftware dot de

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).