🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Andreas Schwab Mon, 23 Nov 1992 11:54
GCC 2.3.1: bug in combine pass
#1475
Author: Andreas Schwab
Date: Mon, 23 Nov 1992 11:54
63 lines
1758 bytes
GCC 2.3.1 (m68k, Atari TT) generates wrong code for this file:

---------- test.c
typedef struct
{
  unsigned short b0, b1, b2, b3;
} four_quarters;

four_quarters x;
int a, b;

void f (four_quarters j)
{
  b = j.b2;
  a = j.b3;
}
----------

Compiled with: gcc -O -S test.c

---------- test.s
#NO_APP
gcc2_compiled.:
.text
	.even
.globl _f
_f:
	link a6,#0
	movel d2,sp@-
	movel a6@(8),d1
	movel a6@(12),d2
	movel d2,d0
	clrw d0
	swap d0
	movel d0,_b
	clrw _a
	movew d1,_a+2		| <--- should be d2
	movel a6@(-4),d2
	unlk a6
	rts
.comm _x,8
.comm _a,4
.comm _b,4
----------

I suppose that the bug is in combine.c (make_extraction), near line 4630:

----------
      else if (GET_CODE (inner) == REG)
	/* We can't call gen_lowpart_for_combine here since we always want
	   a SUBREG and it would sometimes return a new hard register.  */
	new = gen_rtx (SUBREG, tmode, inner,
		       (WORDS_BIG_ENDIAN
			&& GET_MODE_SIZE (is_mode) > UNITS_PER_WORD
			? ((GET_MODE_SIZE (is_mode) - GET_MODE_SIZE (tmode))
			   / UNITS_PER_WORD)
			: 0));
----------

If `is_mode' is changed to `inner_mode' (in both places), the bug disappears.
--
Andreas Schwab
schwab@ls5.informatik.uni-dortmund.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads