Skip to content

Commit 4277298

Browse files
authored
Add a test case
1 parent ba1ddb3 commit 4277298

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/assembly/x86_64-bigint-sub.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//@ only-x86_64
2+
//@ assembly-output: emit-asm
3+
//@ compile-flags: --crate-type=lib -O -C target-cpu=x86-64-v4
4+
//@ compile-flags: -C llvm-args=-x86-asm-syntax=intel
5+
6+
#![no_std]
7+
#![feature(bigint_helper_methods)]
8+
9+
// This checks that the `borrowing_sub` implementation successfully chains, to catch
10+
// issues like <https://github.com/rust-lang/rust/issues/85532#issuecomment-2495119815>
11+
12+
// This forces the ABI to avoid the windows-vs-linux ABI differences.
13+
14+
// CHECK-LABEL: bigint_chain_borrowing_sub:
15+
#[no_mangle]
16+
pub unsafe extern "sysv64" fn bigint_chain_borrowing_sub(
17+
dest: *mut u64,
18+
src1: *const u64,
19+
src2: *const u64,
20+
n: usize,
21+
mut carry: bool,
22+
) -> bool {
23+
// CHECK: mov [[TEMP:r..]], qword ptr [rsi + 8*[[IND:r..]] + 8]
24+
// CHECK: sbb [[TEMP]], qword ptr [rdx + 8*[[IND]] + 8]
25+
// CHECK: mov qword ptr [rdi + 8*[[IND]] + 8], [[TEMP]]
26+
// CHECK: mov [[TEMP]], qword ptr [rsi + 8*[[IND]] + 16]
27+
// CHECK: sbb [[TEMP]], qword ptr [rdx + 8*[[IND]] + 16]
28+
// CHECK: mov qword ptr [rdi + 8*[[IND]] + 16], [[TEMP]]
29+
for i in 0..n {
30+
(*dest.add(i), carry) = u64::borrowing_sub(*src1.add(i), *src2.add(i), carry);
31+
}
32+
carry
33+
}

0 commit comments

Comments
 (0)