-
Couldn't load subscription status.
- Fork 18.4k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Performance
Milestone
Description
What version of Go are you using?
go version go1.12.7 windows/amd64
What did you do?
func bitTestArith(i int) int {
if i%2 != 0 {
return 1
}
return 0
}
func bitTestBinary(i int) int {
if i&1 != 0 {
return 1
}
return 0
}What did you expect to see?
The two conditions in the if statements compile to the same code.
What did you see instead?
The first condition is compiled to:
movq 0x8(sp), ax
movq ax, cx
shrq $0x3f, ax
addq cx, ax
sarq $0x1, ax
shlq $0x1, ax
cmpq ax, cx
je 0x1b9dbb (line 13, varalignblock.go:713)
The second condition is compiled to:
movq 0x8(sp), ax
btl $0x0, ax
jae 0x1b9df1 (line 24, varalignblock.go:720)
gmosx, smasher164, mvdan, seebs, niaow and 2 more
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Performance