https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116716
Bug ID: 116716
Summary: gcc.c-torture/execute/pr52286.c seems broken on 16-bit
targets
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: testsuite
Assignee: unassigned at gcc dot gnu.org
Reporter: mikpelinux at gmail dot com
Target Milestone: ---
The pr52286.c test case does the following on 16-bit targets:
long a, b;
asm ("" : "=r" (a) : "0" (0));
b = (~a | 1) & -2038094497L;
if (b >= 0)
abort ();
On xstormy16 (16-bit int/void*, 32-bit long) the code for this at -Os becomes:
main:
mov.w r2,#0
mov r6,r2
bge r7,r2,.L2
callf abort
.L2:
ret
which uses r7 (apparently the high half of the register pair holding a) without
ever initializing it. Similar use of an uninitialized register is seen on the
pdp11.
If we explicitly mark the input as a long:
- asm ("" : "=r" (a) : "0" (0));
+ asm ("" : "=r" (a) : "0" (0L));
the code instead becomes the more reasonable:
main:
mov.w r6,#0
mov.w r7,#0
bge r7,#0,.L2
callf abort
.L2:
mov.w r2,#0
ret
I noticed this when debugging an out-of-tree port to target with 16-bit
int/void* and 32-bit long.