问题描述
我想生成浮点code代表的ARM Cortex-A9。我调查code之间的性能差异与为code只为VFPv3的协处理器产生的NEON协处理器产生。我开始用下面简单的测试程序:
的#define A大小4漂浮A [A大小] = {7.0f,2.0F,3.0F,4.0F};
浮B〔A大小] = {5.0F,6.0f,7.0f,8.0f};
浮C [A大小]诠释主要(无效){
无符号整型我;
对于(i = 0; I< A大小,我++)
{
C [i] = A [I] + B [I]
}
返回0;
}
当我用下面的标志编译
CCFLAGS = -g -c -O3 -mcpu =的cortex-A9 -mfpu =霓虹灯-mfloat-ABI = softfp -ffast-数学-funsafe-数学优化
我从不是GCC或以下汇编输出code的Sourcery精简版的编译器:
9:atest.c **** INT主要(无效){
23的.loc 1 9 0
24 .cfi_startproc
25 @ ARGS = 0,pretend = 0,帧= 0
26 @ frame_needed = 0,uses_anonymous_args = 0
27 @链接寄存器保存淘汰。
10:atest.c ****
11:atest.c ****无符号整型我;
12:atest.c ****
13:atest.c ****为(i = 0; I< A大小,我++)
14:atest.c **** {
15:atest.c **** C [i] = A [I] + B [I]
28的.loc 1月15日0
29 0000 003000E3 MOVW R3,#:lower16:.LANCHOR0
30 0004 002000E3 MOVW R2,#:lower16:C
31 0008 003040E3 MOVT R3,#:upper16:.LANCHOR0
32 000C DF2A63F4 vld1.64 {D18-D19},[R3:64]
33 0010 040BD3ED VLDR D16,[R3,#16]
34 0014 061BD3ED VLDR D17,[R3,#24]
35 0018 E00D42F2 vadd.f32 Q8,Q9,Q8
36 001C 002040E3 MOVT R2,#:upper16:C
16:atest.c ****}
17:atest.c ****
18:atest.c ****返回0;
19:atest.c ****}
这是我所期待看到的。浮点指令是在VXXX的形式。
现在当我改变了编译器标志-mfpu = VFPv3的(或任何其他排列如-mfpu =的VFPv3-D16-F16)我看到以下内容:
9:atest.c **** INT主要(无效){
23的.loc 1 9 0
24 .cfi_startproc
25 @ ARGS = 0,pretend = 0,帧= 0
26 @ frame_needed = 0,uses_anonymous_args = 0
27 @链接寄存器保存淘汰。
28 .LVL0:
11:atest.c ****无符号整型我;
13:atest.c ****为(i = 0; I< A大小,我++)
14:atest.c **** {
15:atest.c **** C [i] = A [I] + B [I]
29的.loc 1月15日0
30 0000 003000E3 MOVW R3,#:lower16:.LANCHOR0
31 0004 002000E3 MOVW R2,#:lower16:C
32 0008 003040E3 MOVT R3,#:upper16:.LANCHOR0
33 000C 002040E3 MOVT R2,#:upper16:C
34 0010 004A93ED FLDS S8,[R3]
16:atest.c ****}
18:atest.c ****返回0;
19:atest.c ****}
35的.loc 1 19 0
36 0014 0000A0E3 MOV R0,#0
15:atest.c ****}
37的.loc 1月15日0
38 0018 046A93ED FLDS S12,[R3,#16]
39 001C 014AD3ED FLDS S9,[R 3,#4]
40 0020 056AD3ED FLDS S13,[R3,#20]
41 0024 025A93ED FLDS S10,[R3,#8]
42 0028 067A93ED FLDS S14,[R3,#24]
43 002C 035AD3ED FLDS S11,[R3,#12]
44 0030 077AD3ED FLDS S15,[R3,#28]
45 0034 066A34EE fadds S12,S8,S12
46 0038 A66A74EE fadds S13,S9,S13
47 003C 077A35EE fadds S14,S10,S14
48 0040 A77A75EE fadds S15,S11,S15
49 0044 006A82ED FSTS S12,[R2]
50 .LVL1:
51 0048 016AC2ED FSTS S13,[R2,#4]
52 .LVL2:
53 004C 027A82ED FSTS S14,[R2,#8]
54 .LVL3:
55 0050 037AC2ED FSTS S15,[R2,#12]
56 .LVL4:
57的.loc 1 19 0
58 0054 1EFF2FE1 BX LR
59 .cfi_endproc
60 .LFE0:
61 .fnend
所有浮点汇编指令的形式为FXXX。他们为什么不其形式为VXXX?我期待看到一个看起来像VLD1.32加载指令,并添加看起来像VADD.F32说明。当我搜索的ARM官方文档中的指令FLDS它说,FLDS是在ARM9架构使用,不的Cortex-A9。
我都试过-mcpu,-mfpu,-march编译器标记的每一个组合,但我似乎无法产生浮于形式VXXX点汇编指令使用或者用于Linux的GCC编译器或$ C $ ç巫术精简版的编译器的Linux版本。我在做什么错了?
Absolutely nothing, unless you count using an old disassembler. The instructions are the same, the encodings are the same, it's just the recommended assembly mnemonics that changed. Clearly whatever disassembler you're using (I don't recognise that output format) hasn't been updated since ARM introduced the UAL syntax, so has disassembled to the old mnemonics. Feel free to try another disassembler (e.g. a recent-ish objdump
) to compare, but as I say it's purely a difference in representation - nothing to worry about.
这篇关于为什么GCC产生FXXX,而不是VXXX浮点汇编指令用于Cortex-A9?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!