这是使用-falign-循环选项时,GCC错误? [英] Is this a GCC bug when using -falign-loops option?
问题描述
我在玩此选项可以在我们的嵌入式架构优化的循环(的这里)。然而,我注意到,当对准需要多于一个 NOP
指令以复加,那么编译器生成一个 NOP
其次为一对多,为要求的零( 0000
)。
I was playing with this option to optimize a for-loop in our embedded architecture (here). However, I noticed that when the alignment requires more than a single nop
instruction to be added, then the compiler generates one nop
followed by as-many-as-required zeros (0000
).
我怀疑它是在我们的编译器错误,但有人可以证实这不是在GCC一个错误?
I suspect it is a bug in our compiler, but can someone confirm it is not a bug in GCC?
下面是一个code片断:
Here's a code snippet:
__asm__ volatile("nop");
__asm__ volatile("nop");
for (j0=0; j0<N; j0+=4)
{
c[j0+ 0] = a[j0+ 0] + b[j0+ 0];
c[j0+ 1] = a[j0+ 1] + b[j0+ 1];
c[j0+ 2] = a[j0+ 2] + b[j0+ 2];
c[j0+ 3] = a[j0+ 3] + b[j0+ 3];
}
编译与 -falign-循环= 8
(或任何这比所要求的最小对齐有关您的架构号)。您可以添加或删除在必要时产生错位循环体的 __ ASM __
行。
Compile with -falign-loops=8
(or whatever number relevant to your architecture which is more than the required minimum alignment). You can add or remove the __asm__
lines as necessary to generate misaligned loop body.
推荐答案
使用的gcc -o -S文件foo.c foo.s
来生成汇编输出没有装配它。我怀疑你会看到 .balign
或 .p2align
指令在ASM。假设该指令的目的是工作,我认为这是在汇编中的错误。也有可能你已经把code在非默认的部分(即不的.text
)无论是有意或无意地(例如,使用一个错位的 .DATA
或 .section伪
在其他一些内联汇编);通常汇编垫有适当的大小和数量的 NOP
指令包含code节和0字节包含数据的部分。
Use gcc -S -o foo.s foo.c
to generate the assembly output without assembling it. I suspect you'll see the .balign
or .p2align
directive in the asm. Assuming this directive is intended to work, I think it's a bug in the assembler. It's also possible that you've put the code in a non-default section (i.e. not .text
) either intentionally or accidentally (e.g. with a misplaced .data
or .section
in some other inline asm); normally the assembler pads with the proper size and number of nop
instructions for sections that contain code, and 0 bytes for sections that contain data.
这篇关于这是使用-falign-循环选项时,GCC错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!