After fixing PR 17790, I noticed that Ada still does not bootstrap and looked into it and noticed that doloop is causing wrong code: The RTL looks like: (insn 334 333 429 27 /Volumes/UFS_Partition/pinskia/src/devel/new-fold/gcc/gcc/ada/csets.adb: 1151 (set (reg:SI 118 [ ivtmp.7 ]) (const_int 255 [0xff])) 332 {*movsi_internal1} (nil) (nil)) ... (insn 359 358 360 28 /Volumes/UFS_Partition/pinskia/src/devel/new-fold/gcc/gcc/ada/csets.adb: 1151 (set (reg:SI 278) (plus:SI (reg:SI 118 [ ivtmp.7 ]) (const_int -1 [0xffffffffffffffff]))) -1 (nil) (nil)) (insn 360 359 361 28 /Volumes/UFS_Partition/pinskia/src/devel/new-fold/gcc/gcc/ada/csets.adb: 1151 (set (reg:SI 118 [ ivtmp.7 ]) (zero_extend:SI (subreg:QI (reg:SI 278) 3))) -1 (nil) (nil)) (note 361 360 362 28 ("/Volumes/UFS_Partition/pinskia/src/devel/new-fold/gcc/gcc/ada/ csets.adb") 1150) (insn 362 361 363 28 /Volumes/UFS_Partition/pinskia/src/devel/new-fold/gcc/gcc/ada/csets.adb: 1150 (set (reg:CC 279) (compare:CC (reg:SI 118 [ ivtmp.7 ]) (const_int 0 [0x0]))) -1 (nil) (nil))
I should say that the loop gets turned into a loop which starts at (unsigned)-1 and goes down to 0 which is wrong.
s/17790/17787.
I was able to past the part which I was failing when I reported this bug on powerpc-apple-darwin with the patch for PR 17787 and with BOOT_CFLAGS="-O2 -g -fno-branch-count-reg" so I think doloop is the last bootstrap problem with Ada.
I hear that this also happens on powerpc-linux and using -fno-branch-count-reg fixes the problem there too.
Doloop tries to interpret number of iterations that is computed in QImode in SImode, which causes problems since # of iterations is constant, does not contain information about its mode and gets missinterpreted. I am testing the patch.
Patch: http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00228.html
Subject: Bug 17791 CVSROOT: /cvs/gcc Module name: gcc Changes by: rakdver@gcc.gnu.org 2004-10-07 06:20:35 Modified files: gcc : ChangeLog loop-doloop.c loop-iv.c rtl.h Log message: PR rtl-optimization/17791 * loop-doloop.c (doloop_modify): Take number of iterations as argument. (doloop_optimize): Extend or shorten the number of iterations when changing mode of counter register. * loop-iv.c (lowpart_subreg): Export. * rtl.h (lowpart_subreg): Declare. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.5778&r2=2.5779 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/loop-doloop.c.diff?cvsroot=gcc&r1=2.9&r2=2.10 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/loop-iv.c.diff?cvsroot=gcc&r1=2.20&r2=2.21 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/rtl.h.diff?cvsroot=gcc&r1=1.512&r2=1.513
Fixed.