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

bug report for egcs-1.0.2



There are two problems I found which are specific (it seems) to the
-mamdk5 option. I don't know if I should report it to you or the pgcc
people but anyway here is what I found.

first of all: $ gcc -v
Reading specs from /usr/lib/gcc-lib/i586-pc-linux-gnu/pgcc-2.90.27/specs
gcc version pgcc-2.90.27 980315 (egcs-1.0.2 release)

I include a strange bit of code in c++ that I wrote today. The problem is
that compiling with -mamdk5 -O9 does not produce correct output. All other
combinations of -O and -m seem to produce correct code.

The second thing that concerns me is that -mamdk5 produces less efficient
code on my Amd K5 . This happens only when optimization is turned on. It
seems that -mamdk5 -O is 10% slower that -m386 -O.

Thanks in advance.

Dimitromanolakis Apostolos
#include <iostream.h>

class vlong
	{
		public:
			int s;
			char *d;
			
			vlong(int x=300) { s = x; d = new char [x]; for(int i=0;i<x;i++) d[i]=0; }
			~vlong() { delete d; }
			
			void add(int b);
			void sub(int b);
			int div(int b);
			void mul(int b);
			void print();
			
			int size() { int i; for(i=0;d[i]==0;i++); return s-i; }
	};
		
void vlong::add(int b)
{
for(int i=s-1, j=b; i>=0; i--)
	{
		j += d[i];
		d[i] = j%10;
		j = j/10;		
	}
}

void vlong::sub(int b)
{
for(int i=s-1, j=-b, c=0; i>=0; i--)
	{
		j += d[i]-c;
		
		if(j<0) c=1,j+=10; else c=0;
		
		d[i] = j%10;
		j = j/10;
	}
}

void vlong::mul(int b)
{
for(int i=s-1, j=0; i>=0; i--)
	{
	  j += d[i] * b;
		
		d[i] = j%10;
		j = j/10;		
	}
}

int vlong::div(int b)
{
int j=0;

for(int i=0; i<s; i++)
	{
	  j = 10*j + d[i];
		
		d[i] = j/b;
		j = j % b;
	}

return j;
}

void vlong::print()
{
int i;
for(i=0;d[i]==0;i++);

for(;i<s;i++) cout << (int)d[i];
}

void show(int d,int m)
{
int n;

for(n=1;n<300;n++)
	{
		vlong a;
	
		a.add(1);
		for(int i=0;i<n;i++) a.mul(10);
		a.sub(m);
		a.mul(d);

		int r = a.div(10*m-1);

		if(r==0 && a.size()<=n)
			{
			  for(int k=n;k!=a.size();k--) cout << '0';
				a.print();
				cout << d << '\n';
				
				return;
			}
	}
}

main()
{
int d,m;

for(d=1;d<=9;d++)
	for(m=1;m<=9;m++)
//	cout << d << ' ' << m << '\n';
		show(d,m);
}

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