2
![Stack Overflow](http://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png)
With gcc 6.1 both produce the same assembly:
int f(int n) {
return n % 2 ? -1 : 1;
}
int g(int n) {
return n & 1 ? -1 : 1;
}
Assembly:
f(int):
movl %edi, %eax
andl $1, %eax
negl %eax
orl $1, %eax
ret
g(int):
movl %edi, %eax
...