https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67712
Bug ID: 67712 Summary: [SH] __builtin_strncmp causes code bloat Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: olegendo at gcc dot gnu.org Target Milestone: --- Target: sh*-*-* The test case from gcc.target/sh/cmpstrn.c int test02 (const char *s1) { return __builtin_strncmp (s1, "abcdefghi", 8); } compiled with -m4 -ml -O2: _test02: mov.l .L40,r2 mov r4,r5 mov #8,r7 or r2,r5 mov r5,r0 tst #3,r0 bf/s .L25 mov #0,r3 mov #2,r6 .L5: mov.l @r2+,r1 mov.l @r4+,r5 mov r1,r7 and r5,r7 cmp/str r3,r7 bt/s .L6 cmp/eq r1,r5 bf/s .L6 dt r6 bf/s .L5 mov #0,r0 rts nop .align 1 .L25: mov.b @r2+,r1 tst r1,r1 bt/s .L4 mov.b @r4+,r5 cmp/eq r1,r5 bf/s .L4 extu.b r1,r1 dt r7 bf .L25 .L4: extu.b r5,r0 sub r1,r0 .L39: rts nop .align 1 .L6: add #-4,r2 mov.b @r2,r1 add #-4,r4 tst r1,r1 bt/s .L4 mov.b @r4,r5 cmp/eq r1,r5 bf/s .L4 extu.b r1,r1 mov.b @(1,r4),r0 mov r0,r5 mov.b @(1,r2),r0 tst r0,r0 bt/s .L4 mov r0,r1 cmp/eq r0,r5 bf/s .L4 extu.b r0,r1 mov.b @(2,r4),r0 mov r0,r5 mov.b @(2,r2),r0 tst r0,r0 bt/s .L4 mov r0,r1 cmp/eq r0,r5 bf/s .L4 extu.b r0,r1 mov.b @(3,r4),r0 mov r0,r5 mov.b @(3,r2),r0 tst r0,r0 bt/s .L4 mov r0,r1 cmp/eq r0,r5 bf/s .L4 extu.b r0,r1 mov.b @(4,r4),r0 mov r0,r5 mov.b @(4,r2),r0 tst r0,r0 bt/s .L4 mov r0,r1 cmp/eq r0,r5 bf/s .L4 extu.b r0,r1 mov.b @(5,r4),r0 mov r0,r5 mov.b @(5,r2),r0 tst r0,r0 bt/s .L4 mov r0,r1 cmp/eq r0,r5 bf/s .L4 extu.b r0,r1 mov.b @(6,r4),r0 mov r0,r5 mov.b @(6,r2),r0 tst r0,r0 bt/s .L4 mov r0,r1 cmp/eq r0,r5 bf/s .L4 extu.b r0,r1 mov.b @(7,r4),r0 mov r0,r5 mov.b @(7,r2),r0 tst r0,r0 bt/s .L4 mov r0,r1 extu.b r0,r1 extu.b r5,r0 bra .L39 sub r1,r0 .L41: .align 2 .L40: .long .LC0 .size _test02, .-_test02 The fully unrolled byte loop somehow seems inappropriate...