Andes Workshop
http://forum.andestech.com/

如何使用乘加指令maddr32
http://forum.andestech.com/viewtopic.php?f=14&t=671
Page 1 of 1

Author:  cindy [ Fri Feb 08, 2013 6:18 pm ]
Post subject:  如何使用乘加指令maddr32

Andes compiler會自動產生乘加指令,gcc真是相當聰明呢

舉個例子,程式碼:
int a,b,c,d;
int x1,x2,x3;

int main(void) {
d=a*x1+b*x2+c*x3;
return 0;
}

經過最佳化編譯之後(-O1以上均可,下面是-Os產生的code)
500108: 3c 1c 00 02 lwi.gp $r1,[+#8]
50010c: 3c 0d ff fe lwi.gp $r0,[+#-8]
500110: 42 10 80 24 mul $r1,$r1,$r0
500114: 3c 2c 00 03 lwi.gp $r2,[+#12]
500118: 3c 0d ff ff lwi.gp $r0,[+#-4]
50011c: 42 11 00 73 maddr32 $r1,$r2,$r0
500120: 3c 2c 00 04 lwi.gp $r2,[+#16]
500124: 3c 0c 00 00 lwi.gp $r0,[+#0]
500128: 42 11 00 73 maddr32 $r1,$r2,$r0
50012c: 84 00 movi55 $r0,#0
50012e: 3c 1e 00 01 swi.gp $r1,[+#4]
500132: dd 9e ret5 $lp

第一次用乘,另外兩次用乘加。

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/