2011-08-16 07:58:00     __builtin_bfin_shr macro problems

Document created by Aaronwu Employee on Oct 16, 2013
Version 1Show Document
  • View in full screen mode

2011-08-16 07:58:00     __builtin_bfin_shr macro problems

Kai Iskratsch (AUSTRIA)

Message: 102944   

 

i know that the right shift builtins are not officially mentioned in the builtin_functions list in wiki for gcc, but they are still defined in gcc.h as macros.

 

#define __builtin_bfin_shr_fr1x16(a,b)    __builtin_bfin_shl_fr1x16(a,-(b))

#define __builtin_bfin_shr_fr2x16(a,b)    __builtin_bfin_shl_fr2x16(a,-(b))

#define __builtin_bfin_lshr_fr1x16(a,b)    __builtin_bfin_lshl_fr1x16(a,-(b))

#define __builtin_bfin_lshr_fr2x16(a,b)    __builtin_bfin_lshl_fr2x16(a,-(b))

#define __builtin_bfin_shr_fr1x32(a,b)    __builtin_bfin_shl_fr1x32(a,-(b))

 

 

 

when useing 2 right shifts with these macros by same amount following each other this casues a problem when useing -O2 optimize option.

 

the code we use is like this

 

fract16 a,b;

int shift=3;

.....

__builtin_bfin_shr_fr2x16(a,****);

__builtin_bfin_shr_fr2x16(b,shift);

 

 

 

creates o2 asm code like this

 

... (a and b are in r2 and r7 and shift is in r0)

R0=-R0;

R2=ASHIFT(R2,R0);

R0=-R0;

R7=ASHIFT(R7,R0)

 

this shifts one variable to the right as wanted and the other to the left.

 

 

 

with another bracket around the -(b) in a redefined macro it seems to work for us

QuoteReplyEditDelete

 

 

2011-08-18 10:30:17     Re: __builtin_bfin_shr macro problems

Stuart Henderson (UNITED KINGDOM)

Message: 103000   

 

Hi,

 

sorry for the delay in getting back to you.

 

I'm trying to reproduce the issue you're seeing and currently can't.  Can you provide some code that exhibits this failure as well as the command line you used to compile it?  also, what release of the tools are you using (2010R1, etc) and which toolchain (bfin-uclinux, etc.)?

 

In the code example you provide, you're calling an fr2x16 builtin with fract16 variables, which should fail to compile.

 

Thanks,

Stu

QuoteReplyEditDelete

 

 

2011-09-26 10:46:28     Re: __builtin_bfin_shr macro problems

Kai Iskratsch (AUSTRIA)

Message: 103543   

 

sorry for not getting back to this topic so long.

 

the example was a wrong/copy paste. in the real code i was useing fr1x16 or 1x32 builtins (not sure anymore). and yes i was useing 2010R1 version of the bfin-elf toolchain (baremetal).

 

don't have the exact code anymore now as i used a workaround back then and its been near impossible to find the exact revision number in our svn now.

Attachments

    Outcomes