C ++ - 恒和优化 [英] C++ - constant and optimization

查看:142
本文介绍了C ++ - 恒和优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在优化我的应用程序和编译的一些热点正在使用 GCC-手臂完成的。

I am optimizing some hotspots in my application and compilation is done using gcc-arm.

现在,有没有机会,下面的语句导致不同的汇编code:

Now, is there any chance that the following statements result in different assembler code:

static const pixel_t roundedwhite = 4294572537U;
return (packed >= roundedwhite) ? purewhite : packed;

// OR
const pixel_t roundedwhite = 4294572537U;
return (packed >= roundedwhite) ? purewhite : packed;

// OR
return (packed >= 4294572537U) ? purewhite : packed;

是否有任何机会,我的ARM编译器可能会产生不必要的code为第一种情况下还是应该得到这个优化呢?

Is there any chance that my ARM compiler might produce the unwanted code for the first case or should this get optimized anyway?

我认为这是pretty是相同的,但不幸的是,我不是说知道什么 GCC-手臂确实比普通 GCC ,我无法访问反汇编列表。

I assume that it's pretty the same, but, unfortunately, I am not that sure in what gcc-arm does compared to ordinary gcc and I can't access the disassembly listing.

非常感谢你。

推荐答案

GCC 与 -S 标志,并看一看装配:

Call gcc with the -S flag and take a look at the assembly:

-S

在正常编译阶段后停止;不汇编。输出是每个指定的非汇编输入文件汇编code文件的形式。

Stop after the stage of compilation proper; do not assemble. The output is in the form of an assembler code file for each non-assembler input file specified.

我就出来试试自己的答案,包括但我没有一个ARM编译器派上用场了。

I would it out try myself to include in the answer, but I don't have an ARM compiler handy.

这篇关于C ++ - 恒和优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆