5 ms·
bool b = x < y;
by thwest 12y ago
bool b = x < y;
- nkurz 12y agoIt's a matter of semantics, but this does not contradict the parent. Under-the-hood in assembly, this is split into two operations: a comparison (cmp), and then a second operation that sets 'b'. This could be done with a branch (jl), a conditional move (cmovl), or a conditional set (setl). You can see the various solutions used by different compilers with mattgodbolt's GCC explorer: http://gcc.godbolt.org/#%7B%22version%22%3A3%2C%22filterAsm%22%3A%7B%22labels%22%3Atrue%2C%22directives%22%3Atrue%2C%22commentOnly%22%3Atrue%7D%2C%22compilers%22%3A%5B%7B%22sourcez%22%3A%22JYOwLgBANgpgznA%2BmAFgQxAClJAHgGghwgE8BKCAbwCgIIAjAe0agYgF4JcIAeUgbloQATjDABXYSAaCAvtWpAAA%22%2C%22compiler%22%3A%22%2Fusr%2Fbin%2Fg%2B%2B-4.8%22%2C%22options%22%3A%22-O3%20%20%22%7D%5D%7D http://gcc.godbolt.org/#%7B%22version%22%3A3%2C%22filterAsm%...
- thwest 12y agoOh interesting. Thanks.