GCC-How does the coding style affect the insv pattern recognization?

David Daney ddaney@caviumnetworks.com
Thu Jan 14 22:07:00 GMT 2010


fanqifei wrote:
> 2010/1/13 Bingfeng Mei <bmei@broadcom.com>:
>> Your instruction is likely too specific to be picked up by GCC.
>> You may use an intrinisc for it.
>>
>> Bingfeng
> 
> but insv is a standard pattern name.
> the semantics of expression x= (x&0xFF00FFFF) | ((i<<16)&0x00FF0000);
> is exactly what insv can do.
> I all tried mips gcc cross compiler, and ins is also not generated.

You must be doing something wrong:

$ cat fanqifei.c
struct test_foo {
   unsigned int a:18;
   unsigned int b:2;
   unsigned int c:12;
};

struct test_foo x;

unsigned int foo()
{
   unsigned int a=x.b;
   x.b=2;
   return a;
}

$ mips64-linux-gcc -O3 -march=mips32r2 -mabi=32 -mno-abicalls -S fanqifei.c
$ cat fanqifei.s
	.file	1 "fanqifei.c"
	.section .mdebug.abi32
	.previous
	.gnu_attribute 4, 1
	.text
	.align	2
	.globl	foo
	.set	nomips16
	.ent	foo
	.type	foo, @function
foo:
	.frame	$sp,0,$31		# vars= 0, regs= 0/0, args= 0, gp= 0
	.mask	0x00000000,0
	.fmask	0x00000000,0
	.set	noreorder
	.set	nomacro
	lui	$3,%hi(x)
	lw	$2,%lo(x)($3)
	li	$5,2			# 0x2
	move	$4,$2
	ins	$4,$5,12,2         #<<<<<<< Here it is.
	sw	$4,%lo(x)($3)
	j	$31
	ext	$2,$2,12,2

	.set	macro
	.set	reorder
	.end	foo
	.size	foo, .-foo

	.comm	x,4,4
	.ident	"GCC: (GNU) 4.5.0 20091223 (experimental) [trunk revision 155414]"



More information about the Gcc mailing list