Date: Tue, 7 Mar 2000 10:24:54 +0100 Message-Id: <200003070924.KAA14711@virtutech.se> X-Authentication-Warning: skynet.hq.vtech: mch set sender to mch AT virtutech DOT se using -f From: Magnus Christensson To: pgcc AT delorie DOT com Subject: -fcompare-elim bug Reply-To: pgcc AT delorie DOT com Pgcc 2.95.2 generates broken code with -fcompare-elim enabled. I'm using pgcc version pgcc-2.95.2 19991024 (release) on a GNU/Linux(x86) system. Code from 186.crafty (a specint2000 benchmark): /* enpassant pawns are on either file adjacent to the current file, and on the same rank. */ for (i=0;i<64;i++) mask_eptest[i]=0; for (i=25;i<31;i++) mask_eptest[i]=Or(set_mask[i-1],set_mask[i+1]); for (i=33;i<39;i++) mask_eptest[i]=Or(set_mask[i-1],set_mask[i+1]); mask_eptest[A4]=set_mask[B4]; mask_eptest[H4]=set_mask[G4]; mask_eptest[A5]=set_mask[B5]; mask_eptest[H5]=set_mask[G5]; For the second for loop pgcc generates: ;; mask_eptest: 0x80ae5c0 ;; set_mask: 0x81521c0 ;; Or(a,b) = (a) | (b) ;; -O3 -g -mcpu=pentiumpro -march=pentiumpro 0x805f695 : mov $0xfffffffa,%edi 0x805f69a : mov $0xd0,%ecx 0x805f69f : mov $0xc0,%edx 0x805f6a4 : mov $0xc8,%eax 0x805f6a9 : lea 0x0(%esi,1),%esi 0x805f6b0 : mov 0x81521c0(%edx),%ebx 0x805f6b6 : mov 0x81521c4(%edx),%esi 0x805f6bc : or 0x81521c0(%ecx),%ebx 0x805f6c2 : or 0x81521c4(%ecx),%esi 0x805f6c8 : mov %ebx,0x80ae5c0(%eax) 0x805f6ce : mov %esi,0x80ae5c4(%eax) 0x805f6d4 : add $0x8,%ecx 0x805f6d7 : add $0x8,%edx 0x805f6da : add $0x100,%eax 0x805f6df : add $0x20,%edi 0x805f6e2 : jne 0x805f6b0 The last add instruction will never generate an equal (zero) result, so the loop will go on forever. Code without -fcompare-elim: ;; mask_eptest: 0x80ae580 ;; set_mask: 0x8152180 ;; -O3 -fno-compare-elim -g -mcpu=pentiumpro -march=pentiumpro 0x805f625 : mov $0x19,%edi 0x805f62a : mov $0x8152180,%ecx 0x805f62f : mov $0xd0,%edx 0x805f634 : mov $0xc0,%eax 0x805f639 : lea 0x0(%esi,1),%esi 0x805f640 : mov (%eax,%ecx,1),%ebx 0x805f643 : mov 0x4(%eax,%ecx,1),%esi 0x805f647 : or (%edx,%ecx,1),%ebx 0x805f64a : or 0x4(%edx,%ecx,1),%esi 0x805f64e : mov %ebx,0x80ae580(,%edi,8) 0x805f655 : mov %esi,0x80ae584(,%edi,8) 0x805f65c : add $0x8,%edx 0x805f65f : add $0x8,%eax 0x805f662 : inc %edi 0x805f663 : cmp $0x1e,%edi 0x805f666 : jle 0x805f640 I'm not a member of any pgcc mailing lists, so please cc all follow-ups to mch AT virtutech DOT se. /Magnus