https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83543
Bug ID: 83543 Summary: strlen of a local array member not optimized on some targets Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- 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. $ (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; }