This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Re-run of loop pass
- To: Joern Rennecke <amylaar at cygnus dot co dot uk>
- Subject: Re: Re-run of loop pass
- From: Michael Hayes <m dot hayes at elec dot canterbury dot ac dot nz>
- Date: Thu, 05 Nov 1998 14:01:20 +1300 (NZDT)
- Cc: m dot hayes at elec dot canterbury dot ac dot nz (Michael Hayes), toon at moene dot indiv dot nluug dot nl, rth at cygnus dot com, law at cygnus dot com, egcs at cygnus dot com
- References: <13871.53637.686739.360606@ongaonga.elec.canterbury.ac.nz><199811050034.AAA16468@phal.cygnus.co.uk>
Joern Rennecke writes:
> I have the suspicion that this will miscompile this testcase:
>
> int
> f (unsigned start)
> {
> int i, j;
>
> for (j = 0, i = start; i < start + 5; i++)
> j++;
> return j;
> }
>
> int
> main ()
> {
> int i;
>
> i = f (0U-1);
> if (i)
> abort ();
> exit (0);
> }
The generated code executes correctly on the C4x.
On a 2's complement machine, start is UINT_MAX, start + 5 is 4
due to unsigned arithmetic, i is assigned -1, and j is assigned 0.
The test fails immediately since an unsigned compare is performed
and (unsigned int) -1 is not less than 4. f() thus returns 0.
Michael.