-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Open
Description
Example 1:
export fn rotate(x: u64, y: u64) u64 {
return x >> @truncate(~y) | x << @truncate(y + 1);
}Should be:
rotate:
lea ecx, [rsi + 1]
mov rax, rdi
rol rax, cl
retExample 2:
export fn rotate2(x: u64, y: u64) u64 {
return x >> @truncate(y + 1) | x << @truncate(~y);
}Should be:
rotate2:
lea ecx, [rsi + 1]
mov rax, rdi
ror rax, cl
retMight not be useful in most situations, but these are also valid transformations:
rotate:
mov rcx, rsi
not cl
mov rax, rdi
ror rax, cl
ret
rotate2:
mov rcx, rsi
not cl
mov rax, rdi
rol rax, cl
ret