Subject: Re: More gcc 7.2.7 problems
To: Michael Graff <explorer@flame.org>
From: Thomas Graichen <graichen@omega.physik.fu-berlin.de>
List: port-i386
Date: 01/08/1996 15:38:49
hasn't Michael Graff said ? ...
gcc-7.2.7 - where can i get this ? :-)

i don't know if the workaround for the -fstrenght-reduce bug is in
NetBSD-current ? - here's a mail about it from the FreeBSD lists -
maybe it will help:

*** begin ***

The strength-reduction optimization in gcc 2.7.2 (and earlier) can
produce incorrect code on the i386 platform.

The problem is that the giv chosen to eliminate a biv may overflow,
causing comparisons to fail.  The temporary solution is to simply
prevent the elimination.  A more complete solution would use initial
and final value information to assert that the replacement remains in
range for the type.

Another way the optimization might be retained is if the loop is
transformed to:

	if (x < end) { do { ... } while (x != end); }

Naturally, there are some severe restrictions on when this might be
used, but a number of simple ones (such as the example below) that
could benefit.

Here is an example that reproduces the bug:
- ------------------------------------------------------------
int A[3];
unsigned int B = 3;
 
void printit(void)
{
    int i;
    for(i = 0; i < B; i++)
	printf("A[%d] = %d\n", i, A[i]);
}
 
int main()
{
    int i;
    for(i = 0; i < B; i++)
	A[i] = i-3;
    printit();
    return 0;
}
- ------------------------------------------------------------

Here is a patch that defeats the elimination of a biv involved in a
comparison. 
- ------------------------------------------------------------
*** loop.c.orig	Tue Oct  3 11:17:16 1995
- --- loop.c	Tue Dec 19 19:38:29 1995
*************** maybe_eliminate_biv_1 (x, insn, bl, elim
*** 6119,6124 ****
- --- 6119,6127 ----
        else
  	break;
  
+       /* Unless we can assert that the replacement giv does not 
+          overflow, we cannot (simply) eliminate the biv. */
+ #if 0
        if (CONSTANT_P (arg))
  	{
  	  /* First try to replace with any giv that has constant positive
*************** maybe_eliminate_biv_1 (x, insn, bl, elim
*** 6264,6269 ****
- --- 6267,6273 ----
  	    }
  #endif
  	}
+ #endif
  
        /* If we get here, the biv can't be eliminated.  */
        return 0;
- ------------------------------------------------------------


r~

------- End of Forwarded Message
-- 

	With best regards -- Andrew Stesin.

	+380 (44) 2760188	+380 (44) 2713457	+380 (44) 2713560

	An undocumented feature is a coding error.


*** end ***

> 
> 
> I had a problem with pcvt on one machine using gcc7.2.2 with -O6.  Once I
> changed it to -O, things work again.
> 
> I don't have time to debug things properly right now, but just in case
> others are having problems as well that is a workaround.
> 
> --Michael
> 
> 
  _______________________________________________________||___________________
                                                   __||
  Perfection is reached, not when there is no  __||     thomas graichen
  longer anything to add, but when there   __||    freie universitaet berlin
  is no longer anything to take away   __||           fachbereich physik
                                   __||                      
  - Antoine de Saint-Exupery - __||        graichen@mail.physik.fu-berlin.de
  ___________________________||__________________graichen@FreeBSD.org_________