This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

A fix for another doloop problem


The attached testcase, distilled from ncurses, fails on powerpc-linux
due to getting the loop count wrong.

$ gcc-curr/gcc/xgcc -Bgcc-curr/gcc/ -O2 -o loop loop.c
$ ./loop 
Segmentation fault (core dumped)

Fixed like this:

	* doloop.c (doloop_modify_runtime <biv skips initial incr>): Adjust
	by absolute loop increment, not loop increment.

Currently bootstrapping powerpc-linux.  Assuming bootstrap and
regression tests pass, I'd like to commit the patch and testcase
to both mainline and 3.2 branch.  OK?

Index: gcc/doloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doloop.c,v
retrieving revision 1.23
diff -u -p -r1.23 doloop.c
--- gcc/doloop.c	22 Sep 2002 14:09:30 -0000	1.23
+++ gcc/doloop.c	26 Sep 2002 03:39:30 -0000
@@ -668,8 +668,8 @@ doloop_modify_runtime (loop, iterations_
 	    fprintf (loop_dump_stream,
 	         "Doloop: Basic induction var skips initial incr.\n");
 
-	  diff = expand_simple_binop (mode, PLUS, diff, increment, diff,
-				      unsigned_p, OPTAB_LIB_WIDEN);
+	  diff = expand_simple_binop (mode, PLUS, diff, GEN_INT (abs_inc),
+				      diff, unsigned_p, OPTAB_LIB_WIDEN);
 	}
     }
 
-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

Attachment: loop.c
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]