Open
Description
This is implementation of less-than of 2x i64
multi-precision integer done by checking the carry flag from subtraction.
https://godbolt.org/z/Kbhnq8c91
define i1 @subcarry_ult_2x64(i64 %x0, i64 %x1, i64 %y0, i64 %y1) nounwind {
%b0 = icmp ult i64 %x0, %y0
%d1 = sub i64 %x1, %y1
%b10 = icmp ult i64 %x1, %y1
%b0z = zext i1 %b0 to i64
%b11 = icmp ult i64 %d1, %b0z
%b1 = or i1 %b10, %b11
ret i1 %b1
}
Output:
subcarry_ult_2x64:
sub rsi, rcx
setb cl
cmp rdi, rdx
sbb rsi, 0
setb al
or al, cl
ret
Expected:
subcarry_ult_2x64:
cmp rdi, rdx
sbb rsi, rcx
setb al
retq