为什么较大的比较会变成1行汇编代码? [英] Why did a large comparison become 1 line of assembler code?
本文介绍了为什么较大的比较会变成1行汇编代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在在此处评论中的建议之后,我试图了解
Following a suggestion in a comment here, I'm trying to understand how does Compiler Explorer work. My input is the following piece of code:
int main() {
double x,y,x0,y0,x1,y1;
x = 10;
y = 10;
x0 = 5;
y0 = 5;
x1 = 15;
y1 = 15;
if (x > x0 && x < x1 && y > y0 && y < y1)
return 1;
return 0;
}
结果是:
mov eax, 1
ret
很多年前,我已经学习了汇编程序的基础知识,但是我不知道这是否有意义.可以? (我试图找到的是,如果在两次收益之间添加"else"会不会对性能产生任何影响.根据此网站,这没有.但是我说对了吗?)
I have learned the basics of assembler many years ago, but I don't know if, or how, this makes any sense. Does it? (What I was trying to find is if adding an "else" between the two returns would have any difference in performance. According to this site, it doesn't. But am I getting it right?)
推荐答案
条件为true.编译器对其进行了优化.它会为return 1;
生成代码.
The condition is true. The compiler optimizes it out; it generates code for return 1;
.
这篇关于为什么较大的比较会变成1行汇编代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文