https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69713
Bug ID: 69713 Summary: Invalid code of optimization in SH Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ysato at users dot sourceforge.jp Target Milestone: --- Created attachment 37619 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37619&action=edit reproduce code Attached code compiled. Getting output below. 82 lookup_user_key: 83 mov.l r8,@-r15 84 mov #0,r3 85 mov.l r9,@-r15 86 mov #15,r1 87 mov.l r10,@-r15 88 mov.l r11,@-r15 89 mov r5,r11 90 mov.l r12,@-r15 91 mov r4,r12 92 mov.l r13,@-r15 93 mov.l r14,@-r15 94 sts.l pr,@-r15 95 add #-76,r15 96 mov r15,r2 97 mov.l r6,@(4,r15) 98 add #16,r2 99 .L16: 100 add #-1,r1 101 mov.l r3,@r2 102 tst r1,r1 103 add #4,r2 104 bf .L16 105 mov.l .L111,r1 106 mov r12,r10 107 add #8,r10 108 mova .L21,r0 109 mov.l r1,@(32,r15) 110 mov r10,r2 111 mov #1,r1 112 mov.l r1,@(48,r15) 113 add r2,r2 114 mov.w @(r0,r2),r1 Line 114 is lookup jump table. But not check offset range. So if r2 is out of range (in default case). Refer out of table. -O0 generate collect code. I think optimizing bug.