Non-optimal access to constants

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I use gcc-4.1.2 for MIPS64 configured as

/tmp/gcc-4.1.2/configure --target=mips64-none-elf --enable-threads=no
--disable-shared --enable-long-long --enable-c99 --enable-languages=c
--enable-multilib --enable-symvers=gnu --disable-libmudflap
--disable-libssp --disable-libgcc_eh --with-newlib --with-dwarf2
--with-system-zlib --enable-checking=release
--enable-generated-files-in-srcdir --verbose --prefix=/home/niva/local
--srcdir=/tmp/gcc-4.1.2 --enable-cpp

I compile the file poly.c:

  double poly(double x)
  {
    double y = 1.0 + x * (2.0 + x * (3.0 + x * (4.0 + x)));
    return y;
  } 

using the following command line:

mips64-none-elf-gcc-4.1.2 -O3 -fno-merge-constants -mips64 -Wall -W -S
-o ttt.s ttt.c -G0

(I cannot use -G8 because the operating environment does not allow use
of .sdata sections.)

The resulting assembler code looks like this:
	.rdata
	.align	3
$LC0:
	.word	1074790400
	.word	0
	.align	3
$LC1:
	.word	1074266112
	.word	0
	.align	3
$LC2:
	.word	1073741824
	.word	0
	.align	3
$LC3:
	.word	1072693248
	.word	0
	.text
	.align	2
	.align	3
	.globl	poly
	.ent	poly
poly:
	.frame	$sp,0,$31		# vars= 0, regs= 0/0, args= 0, gp= 0
	.mask	0x00000000,0
	.fmask	0x00000000,0
	.set	noreorder
	.set	nomacro
	

	lui	$2,%hi($LC0)	
	ldc1	$f0,%lo($LC0)($2)
	lui	$2,%hi($LC1)	 
	ldc1	$f1,%lo($LC1)($2)
	add.d	$f0,$f12,$f0	 
	lui	$2,%hi($LC2)	 
	madd.d	$f0,$f1,$f12,$f0
	ldc1	$f1,%lo($LC2)($2)
	lui	$2,%hi($LC3)	 
	madd.d	$f0,$f1,$f12,$f0
	ldc1	$f1,%lo($LC3)($2)
	j	$31
	madd.d	$f0,$f1,$f12,$f0

Two commands are used to access each constant.

Q: Is it possible to make GCC use a common base register for
accessing all of the constants in a function?






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux