哪种 switch 语句产生效率最低的机器代码?

发布于 2024-12-27 00:33:56 字数 87 浏览 4 评论 0原文

我在一项测试中遇到了一个问题,要求我回答哪种 switch 语句会产生效率最低的机器代码。可能的答案是 O4、O1、O2 或 O3。我根本不知道这些是什么意思。

I've got a question in one of my tests that asked me to answer what switch statement produce the least efficient machine code. The possible answers were O4, O1, O2, or O3. I don't event know what those are supposed to mean.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬花如无物 2025-01-03 00:33:56

GCC 控制优化的选项

-O
-O1
优化。对于大型函数来说,优化编译会花费更多的时间和更多的内存。

-O2
进一步优化。 GCC 执行几乎所有支持的优化,不涉及空间速度权衡。与 -O 相比,此选项增加了编译时间和生成代码的性能。

-O3
进一步优化

-操作系统
优化尺寸。

-奥法斯特
无视严格的标准合规性。 -Ofast 启用所有 -O3 优化。它还可以实现并非对所有标准兼容程序都有效的优化

GCC Options That Control Optimization

-O
-O1
Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function.

-O2
Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. As compared to -O, this option increases both compilation time and the performance of the generated code.

-O3
Optimize yet more

-Os
Optimize for size.

-Ofast
Disregard strict standards compliance. -Ofast enables all -O3 optimizations. It also enables optimizations that are not valid for all standard compliant programs

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文