[Bug rtl-optimization/96015] [10/11 Regression] gcc-10.1.0 miscompiles Python on hppa
slyfox at inbox dot ru
gcc-bugzilla@gcc.gnu.org
Fri Jul 3 07:19:44 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96015
--- Comment #27 from Sergei Trofimovich <slyfox at inbox dot ru> ---
If it's of any help by slightly expanding case switch I reproduced very similar
problem on both hppa and sh4 (but not on sparc or mips) with:
"""
int b, c;
int a() __attribute__((noipa));
int a(int *d, int *f, int g) {
int e;
if (d == f)
e = 0;
else
e = 1;
switch (g) {
case 0:
return e;
case 1:
return 7;
case 2:
return 8;
case 3:
return 8;
case 4:
return 1;
case 5:
if (e)
return 10;
default:
__builtin_unreachable();
}
}
int main() { return a(&b, &c, 0); }
"""
$ sh4-unknown-linux-gnu-gcc -fno-PIE -no-pie -fno-stack-protector
-U_FORTIFY_SOURCE -O2 bug_test.c -o bad-bug; ./bad-bug; echo $?
8
$ sh4-unknown-linux-gnu-gcc -fno-PIE -no-pie -fno-stack-protector
-U_FORTIFY_SOURCE -O2 -fno-delayed-branch bug_test.c -o good-bug; ./good-bug;
echo $?
1
bad-bug.S:
a:
cmp/eq r4,r5 ; if (d == f) // not our case
bt/s .L21 ; goto .L21; something complicated on jump tables
mov #5,r1 ; +delay slot
.L6:
.align 1
.L13:
.align 1
.L14:
rts ; return 8
mov #8,r0 ; +delay slot
.align 1
.L17:
rts
mov #1,r0
.align 1
.L21:
mov #4,r1
cmp/hi r1,r6
bt/s .L6
mov r6,r2
mova .L8,r0
add r2,r2
mov.w @(r0,r2),r1
braf r1
nop
.L9:
.align 2
.L8:
.word .L10-.L9
.word .L15-.L9
.word .L14-.L9
.word .L14-.L9
.word .L17-.L9
.align 1
.L15:
rts
mov #7,r0
.align 1
.L10:
rts
mov r6,r0
good-bug.S:
a:
cmp/eq r4,r5
bt .L21
mov #5,r1
cmp/hi r1,r6
bf .L22
.L6:
.align 1
.L22:
mova .L12,r0
mov.b @(r0,r6),r6
braf r6
nop
.L13:
.align 2
.L12:
.byte .L17-.L13
.byte .L15-.L13
.byte .L14-.L13
.byte .L14-.L13
.byte .L17-.L13
.byte .L11-.L13
.align 1
.L14:
mov #8,r0
rts
nop
.align 1
.L17:
mov #1,r0
rts
nop
.align 1
.L21:
mov #4,r1
cmp/hi r1,r6
bt .L6
mova .L8,r0
mov r6,r2
add r2,r2
mov.w @(r0,r2),r1
braf r1
nop
.L9:
.align 2
.L8:
.word .L10-.L9
.word .L15-.L9
.word .L14-.L9
.word .L14-.L9
.word .L17-.L9
.align 1
.L15:
mov #7,r0
rts
nop
.align 1
.L11:
mov #10,r0
rts
nop
.align 1
.L10:
mov r6,r0
rts
nop
Might be not backend-specific? Or pa and sh have a similar bug.
More information about the Gcc-bugs
mailing list