#include <algorithm> int f(int x, int y) { return x > y ? x : y; } int g(int x, int y) { return std::max(x, y); }
sh-3.2$ clang++ -O2 -S foo.cc
.section __TEXT,__text,regular,pure_instructions .build_version macos, 10, 14 .globl __Z1fii ## -- Begin function _Z1fii .p2align 4, 0x90 __Z1fii: ## @_Z1fii .cfi_startproc ## %bb.0: pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset %rbp, -16 movq %rsp, %rbp .cfi_def_cfa_register %rbp cmpl %esi, %edi cmovgel %edi, %esi movl %esi, %eax popq %rbp retq .cfi_endproc ## -- End function .globl __Z1gii ## -- Begin function _Z1gii .p2align 4, 0x90 __Z1gii: ## @_Z1gii .cfi_startproc ## %bb.0: pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset %rbp, -16 movq %rsp, %rbp .cfi_def_cfa_register %rbp cmpl %esi, %edi cmovll %esi, %edi movl %edi, %eax popq %rbp retq .cfi_endproc ## -- End function .subsections_via_symbols
Ads
-O2 gen code係無分別。