Skip to content

Commit

Permalink
Fix off-by-one error uncovered by std::simd tests
Browse files Browse the repository at this point in the history
  • Loading branch information
calebzulawski committed Nov 6, 2021
1 parent 3981ca0 commit 569c51d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ fn generic_simd_intrinsic(
let (len, _) = arg_tys[1].simd_size_and_type(bx.tcx());

let expected_int_bits = (len.max(8) - 1).next_power_of_two();
let expected_bytes = len / 8 + ((len % 8 > 1) as u64);
let expected_bytes = len / 8 + ((len % 8 > 0) as u64);

let mask_ty = arg_tys[0];
let mask = match mask_ty.kind() {
Expand Down Expand Up @@ -1073,7 +1073,7 @@ fn generic_simd_intrinsic(
// * an array of `u8`
// If the vector has less than 8 lanes, a u8 is returned with zeroed trailing bits.
let expected_int_bits = in_len.max(8);
let expected_bytes = expected_int_bits / 8 + ((expected_int_bits % 8 > 1) as u64);
let expected_bytes = expected_int_bits / 8 + ((expected_int_bits % 8 > 0) as u64);

// Integer vector <i{in_bitwidth} x in_len>:
let (i_xn, in_elem_bitwidth) = match in_elem.kind() {
Expand Down

0 comments on commit 569c51d

Please sign in to comment.