Bug 32401 - [PPC/Altivec] Non optimal code structure with -mabi=altivec
Summary: [PPC/Altivec] Non optimal code structure with -mabi=altivec
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on: 32429
Blocks:
  Show dependency treegraph
 
Reported: 2007-06-19 07:36 UTC by Przemysław Iskra
Modified: 2007-07-03 16:35 UTC (History)
4 users (show)

See Also:
Host: powerpc*-linux
Target: powerpc*-linux
Build: powerpc*-linux
Known to work:
Known to fail: 4.3.0
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Przemysław Iskra 2007-06-19 07:36:31 UTC
With altivec enabled gcc prepares additional space on the stack. Unlike earlier versions gcc 4.3 removes stack modification instructions if it isn't used. With just -maltivec or with -mabi=altivec when altivec isn't used it works very well. But with -mabi=altivec and altivec used gcc produces code with stucture similar to one produced by eariler gcc versions with just stack modification instructions removed. Seems like stack isn't optimized early enough.


This simple code:

void
test ( int len )
{
	if (len) {
		vector unsigned char vSetTo = {};
		asm volatile ("" : : "v" (vSetTo) ); /* do something */
	}
}


"gcc-4.3 -O2 -maltivec -mregnames test.c -S" produces:

test:
	cmpwi %cr7,%r3,0
	beqlr- %cr7
	vxor %v0,%v0,%v0
	blr


while "gcc-4.3 -O2 -maltivec -mabi=altivec -mregnames test.c -S" produces:

test:
	cmpwi %cr7,%r3,0
	beq- %cr7,.L3      # <-- should be beqlr
	vxor %v0,%v0,%v0
.L3:
	blr


The letter one has same structure as produced by earlier gcc versions, but without stack modification instructions:

gcc 4.1.3 produces:

test:
	cmpwi %cr7,%r3,0
	stwu %r1,-16(%r1)
	vxor %v0,%v0,%v0
	beq- %cr7,.L4
.L4:
	addi %r1,%r1,16
	blr