This is the mail archive of the gcc@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]

Bug in gcc-20011231



Given the testfile:

#include <stdio.h>

typedef unsigned char ufix8;

ufix8 val = 1;
ufix8 expected = 1;

main(int argc, char *argv[])
{
  ufix8 result;

  result = val % 6;
  if (result != expected) {
    fprintf(stderr,"Huh? modulus is %d\n", result);
    exit(-1);
  }
  return(0);
}


and gcc:

[pbarada: /tmp] > /tmp/crap8/bin/i686-linux-gcc -v
Reading specs from /tmp/crap8/bin/../lib/gcc-lib/i686-linux/3.1/specs
Configured with: /home/pbarada/work/cvs-wavemark/cross-linux-tools/gcc-20011231/configure --target=i686-linux --prefix=/tmp/crap8/ --enable-languages=c --with-local-prefix=/tmp/crap/i686-linux
Thread model: single
gcc version 3.1 20011231 (experimental)


The results are:

[pbarada: /tmp] > /tmp/crap8/bin/i686-linux-gcc -O -o test2 test2.c
[pbarada: /tmp] > ./test2
Huh? modulus is 135

The code generated is:

main:
.LFB1:
.LM1:
	pushl	%ebp
.LCFI0:
	movl	%esp, %ebp
.LCFI1:
	subl	$24, %esp
.LCFI2:
	andl	$-16, %esp
.LBB2:
.LM2:
	movzbl	val, %edx
	movzbw	%dl, %ax
	imull	$-85, %eax, %eax
	shrl	$8, %eax
	movb	%al, %cl
	shrb	$2, %cl
	movb	%cl, %al
	addb	%al, %al
	addb	%cl, %al
	addb	%al, %al
	movb	%dl, %cl
	subb	%al, %cl
.LM3:
	cmpb	expected, %cl


Which looks bizzare.  I tried moduluses of 3, 5, 10, all of which
produced incorrect results.

Any ideas?


-- 
Peter Barada                                   Peter.Barada@motorola.com
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)


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