This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/83543] strlen of a local array member not optimized on some targets
- From: "ramana at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 20 Feb 2018 10:10:39 +0000
- Subject: [Bug tree-optimization/83543] strlen of a local array member not optimized on some targets
- Auto-submitted: auto-generated
- References: <bug-83543-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83543
Ramana Radhakrishnan <ramana at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2018-02-20
CC| |ramana at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #4 from Ramana Radhakrishnan <ramana at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #0)
> Bug 83462 reports (among others) a failure in the new
> c-c++-common/Warray-bounds-4.c test on powerpc64le. The failure is due to a
> strlen optimization that's for some reason not working on this target (and
> on some others, including arm-none-eabi) but that works fine on
> x86_64-linux. The test case below shows the difference in cross-compiler
> output between these three architectures.
Is this because arm-none-eabi by default is a STRICT_ALIGNMENT target ? What
happens if for instance you try this with -march=armv7-a where we allow some
limited misaligned access ?
Ramana
>
> $ (set -x && cat z.c && for arch in '' arm-none-eabi powerpc64le-linux; do
> /ssd/build/$arch/gcc-git/gcc/xgcc -B /ssd/build/$arch/gcc-git/gcc -O2 -S
> -Wall -fdump-tree-optimized=/dev/stdout z.c; done)
> + cat z.c
> struct S { char a[7]; };
>
> void f (void)
> {
> struct S s = { "12345" };
> if (__builtin_strlen (s.a) != 5)
> __builtin_abort ();
> }
> + for arch in ''\'''\''' arm-none-eabi powerpc64le-linux
> + /ssd/build//gcc-git/gcc/xgcc -B /ssd/build//gcc-git/gcc -O2 -S -Wall
> -fdump-tree-optimized=/dev/stdout z.c
>
> ;; Function f (f, funcdef_no=0, decl_uid=1894, cgraph_uid=0, symbol_order=0)
>
> f ()
> {
> <bb 2> [local count: 1073741825]:
> return;
>
> }
>
>
> + for arch in ''\'''\''' arm-none-eabi powerpc64le-linux
> + /ssd/build/arm-none-eabi/gcc-git/gcc/xgcc -B
> /ssd/build/arm-none-eabi/gcc-git/gcc -O2 -S -Wall
> -fdump-tree-optimized=/dev/stdout z.c
>
> ;; Function f (f, funcdef_no=0, decl_uid=4155, cgraph_uid=0, symbol_order=0)
>
> f ()
> {
> struct S s;
> unsigned int _1;
>
> <bb 2> [local count: 1073741825]:
> s = *.LC0;
> _1 = __builtin_strlen (&s.a);
> if (_1 != 5)
> goto <bb 3>; [0.00%]
> else
> goto <bb 4>; [99.96%]
>
> <bb 3> [count: 0]:
> __builtin_abort ();
>
> <bb 4> [local count: 1073312327]:
> s ={v} {CLOBBER};
> return;
>
> }
>
>
> + for arch in ''\'''\''' arm-none-eabi powerpc64le-linux
> + /ssd/build/powerpc64le-linux/gcc-git/gcc/xgcc -B
> /ssd/build/powerpc64le-linux/gcc-git/gcc -O2 -S -Wall
> -fdump-tree-optimized=/dev/stdout z.c
>
> ;; Function f (f, funcdef_no=0, decl_uid=2784, cgraph_uid=0, symbol_order=0)
>
> f ()
> {
> struct S s;
> long unsigned int _1;
>
> <bb 2> [local count: 1073741825]:
> s = *.LC0;
> _1 = __builtin_strlen (&s.a);
> if (_1 != 5)
> goto <bb 3>; [0.00%]
> else
> goto <bb 4>; [99.96%]
>
> <bb 3> [count: 0]:
> __builtin_abort ();
>
> <bb 4> [local count: 1073312327]:
> s ={v} {CLOBBER};
> return;
>
> }