bug in 64x32 support

Doug Evans devans@cygnus.com
Thu Nov 6 16:00:00 GMT 1997


I don't think this is a bug in the sparc backend, per se.
It's a general bug in GCC's 64x32 support which I will happily
let someone else deal with.  This will become more important
as sparc64-linux becomes more prevalent.

fold converts (minus (sym _spBMBtab0) (const -4))
to (plus (sym _spBMBtab0) (const 4294967292)) because pointers
are unsigned and force_fit_type works that way.
output_addr_const then sees this and outputs the assembler shown.
One way to go would be to modify output_addr_const to take this into account,
though this seems like working around a fundamental problem, rather than
being the right fix.

To: bug-gcc@prep.ai.mit.edu
Cc: hiq-gnu@sramhc.sra.co.jp (GNU Project)
Subject: bug in GCC 2.7.2: handling negative number
Date: Wed, 29 Oct 1997 12:04:40 +0900
From: Akiko Matsushita <matusita@sra.co.jp>
Status: OR

-----------------------
version:       2.7.2
configuration: --target=sparc-sun-sunos4.1 --host=alpha-dec-osf3.2
-----------------------

  I tried the following sample.
I think that gcc should generate `sethi %hi(_spBMBtab0-4),%o2', 
instead of                       `sethi %hi(_spBMBtab0+4294967292),%o2'.
So is the line                   `or %o2,%lo(_spBMBtab0+4294967292),%o1'.

---------------------------------------------------
% cat test.c
typedef struct {
  char val, len;
} VLCtab;

static VLCtab spBMBtab0[14] = {
  {8,4},  {8|2,4},  {8|2,4},  {8|2,4},
  {8|2,4},  {8|2,4},  {8|2,4},  {8|2,4},
  {8|2,4},  {8|2,4},  {8|2,4},  {8|2,4},
  {8|2,4},  {8|2,4}
};

static int getspBMBtype()
{
  int code;
  VLCtab *p;

  code = showbits(9);

  if (code>=64)
    p = &spBMBtab0[(code>>5)-2];
}
% gcc -S test.c
% cat test.s

gcc2_compiled.:
___gnu_compiled_c:
.data
_spBMBtab0:
	.byte	8
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
	.byte	10
	.byte	4
.text
	.align 4
	.proc	04
_getspBMBtype:
	!#PROLOGUE# 0
	save %sp,-112,%sp
	!#PROLOGUE# 1
	mov 9,%o0
	call _showbits,0
	nop
	st %o0,[%fp-12]
	ld [%fp-12],%o0
	cmp %o0,63
	ble L2
	nop
	ld [%fp-12],%o1
	sra %o1,5,%o0
	mov %o0,%o1
	sll %o1,1,%o0
	sethi %hi(_spBMBtab0+4294967292),%o2
	or %o2,%lo(_spBMBtab0+4294967292),%o1
	add %o1,%o0,%o0
	st %o0,[%fp-16]
L2:
L1:
	ret
	restore

-----------------------------------------------------------------
 Akiko Matsushita  **         Advanced Technology Group
matusita@sra.co.jp  **  Software Research Associates, Inc., Japan




More information about the Gcc-bugs mailing list