NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: port-sh3/60773: sh3 __sync_val_compare_and_swap_1 test failures



I did the same for Arm with -march=armv5t -mfloat-abi=soft, and here's
how it came out -- gcc treats __sync_* as signed, not unsigned (note
the `and r2, r2, #255' in main__ and main_u8 but not main_s8):

00000000 <main__>:
   0:	e3e01077 	mvn	r1, #119	@ 0x77
   4:	e52de004 	push	{lr}		@ (str lr, [sp, #-4]!)
   8:	e24dd00c 	sub	sp, sp, #12
   c:	e3e0200f 	mvn	r2, #15
  10:	e28d0007 	add	r0, sp, #7
  14:	e5cd1007 	strb	r1, [sp, #7]
  18:	ebfffffe 	bl	0 <__sync_val_compare_and_swap_1>
			18: R_ARM_CALL	__sync_val_compare_and_swap_1
  1c:	e1a02000 	mov	r2, r0
  20:	e3a01088 	mov	r1, #136	@ 0x88
  24:	e20220ff 	and	r2, r2, #255	@ 0xff
  28:	e59f000c 	ldr	r0, [pc, #12]	@ 3c <main__+0x3c>
  2c:	ebfffffe 	bl	0 <printf>
...
00000040 <main_u8>:
  40:	e3e03077 	mvn	r3, #119	@ 0x77
  44:	e52de004 	push	{lr}		@ (str lr, [sp, #-4]!)
  48:	e24dd00c 	sub	sp, sp, #12
  4c:	e3a020f0 	mov	r2, #240	@ 0xf0
  50:	e3a01088 	mov	r1, #136	@ 0x88
  54:	e28d0007 	add	r0, sp, #7
  58:	e5cd3007 	strb	r3, [sp, #7]
  5c:	ebfffffe 	bl	0 <u8_sync_val_compare_and_swap_1>
			5c: R_ARM_CALL	u8_sync_val_compare_and_swap_1
  60:	e3a01088 	mov	r1, #136	@ 0x88
  64:	e1a02000 	mov	r2, r0
  68:	e59f000c 	ldr	r0, [pc, #12]	@ 7c <main_u8+0x3c>
  6c:	ebfffffe 	bl	0 <printf>
...
00000080 <main_s8>:
  80:	e3e01077 	mvn	r1, #119	@ 0x77
  84:	e52de004 	push	{lr}		@ (str lr, [sp, #-4]!)
  88:	e24dd00c 	sub	sp, sp, #12
  8c:	e3e0200f 	mvn	r2, #15
  90:	e28d0007 	add	r0, sp, #7
  94:	e5cd1007 	strb	r1, [sp, #7]
  98:	ebfffffe 	bl	0 <s8_sync_val_compare_and_swap_1>
			98: R_ARM_CALL	s8_sync_val_compare_and_swap_1
  9c:	e1a02000 	mov	r2, r0
  a0:	e3a01088 	mov	r1, #136	@ 0x88
  a4:	e20220ff 	and	r2, r2, #255	@ 0xff
  a8:	e59f000c 	ldr	r0, [pc, #12]	@ bc <main_s8+0x3c>
  ac:	ebfffffe 	bl	0 <printf>
			ac: R_ARM_CALL	printf
...


On sparc, though, as on sh3, __sync_* is treated as unsigned (note the
`and %o0, 0xff, %o2' in main_s8 but not in main__ or main_u8):

00000000 <main__>:
main__():
   0:	9d e3 bf 98 	save  %sp, -104, %sp
   4:	82 10 3f 88 	mov  -120, %g1
   8:	94 10 20 f0 	mov  0xf0, %o2
   c:	c2 2f bf ff 	stb  %g1, [ %fp + -1 ]
  10:	92 10 20 88 	mov  0x88, %o1
  14:	40 00 00 00 	call  14 <main__+0x14>
			14: R_SPARC_WDISP30	__sync_val_compare_and_swap_1
  18:	90 07 bf ff 	add  %fp, -1, %o0
  1c:	92 10 20 88 	mov  0x88, %o1
  20:	94 10 00 08 	mov  %o0, %o2
  24:	b0 10 20 00 	clr  %i0
  28:	11 00 00 00 	sethi  %hi(0), %o0
			28: R_SPARC_HI22	.rodata.str1.8
  2c:	40 00 00 00 	call  2c <main__+0x2c>
			2c: R_SPARC_WDISP30	printf
  30:	90 12 20 00 	mov  %o0, %o0	! 0 <main__>
			30: R_SPARC_LO10	.rodata.str1.8
  34:	81 c7 e0 08 	ret 
  38:	81 e8 00 00 	restore 

0000003c <main_u8>:
main_u8():
  3c:	9d e3 bf 98 	save  %sp, -104, %sp
  40:	82 10 3f 88 	mov  -120, %g1
  44:	94 10 20 f0 	mov  0xf0, %o2
  48:	c2 2f bf ff 	stb  %g1, [ %fp + -1 ]
  4c:	92 10 20 88 	mov  0x88, %o1
  50:	40 00 00 00 	call  50 <main_u8+0x14>
			50: R_SPARC_WDISP30	u8_sync_val_compare_and_swap_1
  54:	90 07 bf ff 	add  %fp, -1, %o0
  58:	92 10 20 88 	mov  0x88, %o1
  5c:	94 10 00 08 	mov  %o0, %o2
  60:	b0 10 20 00 	clr  %i0
  64:	11 00 00 00 	sethi  %hi(0), %o0
			64: R_SPARC_HI22	.rodata.str1.8
  68:	40 00 00 00 	call  68 <main_u8+0x2c>
			68: R_SPARC_WDISP30	printf
  6c:	90 12 20 00 	mov  %o0, %o0	! 0 <main__>
			6c: R_SPARC_LO10	.rodata.str1.8
  70:	81 c7 e0 08 	ret 
  74:	81 e8 00 00 	restore 

00000078 <main_s8>:
main_s8():
  78:	9d e3 bf 98 	save  %sp, -104, %sp
  7c:	82 10 3f 88 	mov  -120, %g1
  80:	94 10 3f f0 	mov  -16, %o2
  84:	c2 2f bf ff 	stb  %g1, [ %fp + -1 ]
  88:	92 10 3f 88 	mov  -120, %o1
  8c:	40 00 00 00 	call  8c <main_s8+0x14>
			8c: R_SPARC_WDISP30	s8_sync_val_compare_and_swap_1
  90:	90 07 bf ff 	add  %fp, -1, %o0
  94:	92 10 20 88 	mov  0x88, %o1
  98:	94 0a 20 ff 	and  %o0, 0xff, %o2
  9c:	b0 10 20 00 	clr  %i0
  a0:	11 00 00 00 	sethi  %hi(0), %o0
			a0: R_SPARC_HI22	.rodata.str1.8
  a4:	40 00 00 00 	call  a4 <main_s8+0x2c>
			a4: R_SPARC_WDISP30	printf
  a8:	90 12 20 00 	mov  %o0, %o0	! 0 <main__>
			a8: R_SPARC_LO10	.rodata.str1.8
  ac:	81 c7 e0 08 	ret 
  b0:	81 e8 00 00 	restore 


So something screwy is going on with gcc's internal concept of what
signedness to use for __sync_*.



Home | Main Index | Thread Index | Old Index