Date: Tue, 12 Oct 1999 16:33:42 +0200 (MET DST) From: grenie AT math DOT jussieu DOT fr (Loic Grenie) Message-Id: <199910121433.QAA29095@riemann.math.jussieu.fr> To: pgcc AT delorie DOT com Subject: Bug in bug report about sign extension elimination MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Reply-To: pgcc AT delorie DOT com I forgot to send the file... I can be also a little bit more precise. It seems that the compiler is confused about register contents. As far as I can tell it also seems it does not do correct sign extension. It's visible at the end of the first small loop (the one with r++; i++;). Loïc typedef struct { short x1, y1, x2, y2; } BoxRec, *BoxPtr; #define ExchangeRects(a, b) \ { \ BoxRec t; \ \ t = rects[a]; \ rects[a] = rects[b]; \ rects[b] = t; \ } void QuickSortRects(BoxPtr rects, int numRects) { register int y1; register int x1; register int i, j; register BoxPtr r; do { if (numRects == 2) { if (rects[0].y1 > rects[1].y1 || (rects[0].y1 == rects[1].y1 && rects[0].x1 > rects[1].x1)) ExchangeRects(0, 1); return; } ExchangeRects(0, numRects >> 1); y1 = rects[0].y1; x1 = rects[0].x1; /* Partition array */ i = 0; j = numRects; do { r = &(rects[i]); do { r++; i++; } while (i != numRects && (r->y1 < y1 || (r->y1 == y1 && r->x1 < x1))); r = &(rects[j]); do { r--; j--; } while (y1 < r->y1 || (y1 == r->y1 && x1 < r->x1)); if (i < j) ExchangeRects(i, j); } while (i < j); ExchangeRects(0, j); if (numRects-j-1 > 1) QuickSortRects(&rects[j+1], numRects-j-1); numRects = j; } while (numRects > 1); }