@@ -321,13 +321,13 @@ pub(crate) fn codegen_x86_llvm_intrinsic_call<'tcx>(
321
321
let dest = CPlace :: for_ptr ( Pointer :: new ( mem_addr) , a. layout ( ) ) ;
322
322
dest. write_cvalue ( fx, a) ;
323
323
}
324
- "llvm.x86.addcarry.64" => {
324
+ "llvm.x86.addcarry.32" | "llvm.x86.addcarry. 64" => {
325
325
intrinsic_args ! ( fx, args => ( c_in, a, b) ; intrinsic) ;
326
326
let c_in = c_in. load_scalar ( fx) ;
327
327
328
328
llvm_add_sub ( fx, BinOp :: Add , ret, c_in, a, b) ;
329
329
}
330
- "llvm.x86.subborrow.64" => {
330
+ "llvm.x86.subborrow.32" | "llvm.x86.subborrow. 64" => {
331
331
intrinsic_args ! ( fx, args => ( b_in, a, b) ; intrinsic) ;
332
332
let b_in = b_in. load_scalar ( fx) ;
333
333
@@ -361,32 +361,24 @@ fn llvm_add_sub<'tcx>(
361
361
a : CValue < ' tcx > ,
362
362
b : CValue < ' tcx > ,
363
363
) {
364
- assert_eq ! (
365
- a. layout( ) . ty,
366
- fx. tcx. types. u64 ,
367
- "llvm.x86.addcarry.64/llvm.x86.subborrow.64 second operand must be u64"
368
- ) ;
369
- assert_eq ! (
370
- b. layout( ) . ty,
371
- fx. tcx. types. u64 ,
372
- "llvm.x86.addcarry.64/llvm.x86.subborrow.64 third operand must be u64"
373
- ) ;
364
+ assert_eq ! ( a. layout( ) . ty, b. layout( ) . ty) ;
374
365
375
366
// c + carry -> c + first intermediate carry or borrow respectively
376
367
let int0 = crate :: num:: codegen_checked_int_binop ( fx, bin_op, a, b) ;
377
368
let c = int0. value_field ( fx, FieldIdx :: new ( 0 ) ) ;
378
369
let cb0 = int0. value_field ( fx, FieldIdx :: new ( 1 ) ) . load_scalar ( fx) ;
379
370
380
371
// c + carry -> c + second intermediate carry or borrow respectively
381
- let cb_in_as_u64 = fx. bcx . ins ( ) . uextend ( types:: I64 , cb_in) ;
382
- let cb_in_as_u64 = CValue :: by_val ( cb_in_as_u64, fx. layout_of ( fx. tcx . types . u64 ) ) ;
383
- let int1 = crate :: num:: codegen_checked_int_binop ( fx, bin_op, c, cb_in_as_u64) ;
372
+ let clif_ty = fx. clif_type ( a. layout ( ) . ty ) . unwrap ( ) ;
373
+ let cb_in_as_int = fx. bcx . ins ( ) . uextend ( clif_ty, cb_in) ;
374
+ let cb_in_as_int = CValue :: by_val ( cb_in_as_int, fx. layout_of ( a. layout ( ) . ty ) ) ;
375
+ let int1 = crate :: num:: codegen_checked_int_binop ( fx, bin_op, c, cb_in_as_int) ;
384
376
let ( c, cb1) = int1. load_scalar_pair ( fx) ;
385
377
386
378
// carry0 | carry1 -> carry or borrow respectively
387
379
let cb_out = fx. bcx . ins ( ) . bor ( cb0, cb1) ;
388
380
389
- let layout = fx. layout_of ( fx. tcx . mk_tup ( & [ fx. tcx . types . u8 , fx . tcx . types . u64 ] ) ) ;
381
+ let layout = fx. layout_of ( fx. tcx . mk_tup ( & [ fx. tcx . types . u8 , a . layout ( ) . ty ] ) ) ;
390
382
let val = CValue :: by_val_pair ( cb_out, c, layout) ;
391
383
ret. write_cvalue ( fx, val) ;
392
384
}
0 commit comments