Skip to content

Commit

Permalink
Undo the changes to bitmask validation messages
Browse files Browse the repository at this point in the history
  • Loading branch information
farnoy committed Dec 8, 2023
1 parent c2fb555 commit e271119
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
20 changes: 6 additions & 14 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,17 +1549,13 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
}
);

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

require!(
matches!(mask_elem.kind(), ty::Int(_)),
InvalidMonomorphization::InvalidBitmask {
InvalidMonomorphization::ThirdArgElementType {
span,
name,
mask_ty,
expected_int_bits,
expected_bytes
expected_element: values_elem,
third_arg: mask_ty,
}
);

Expand Down Expand Up @@ -1645,17 +1641,13 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
}
);

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

require!(
matches!(mask_elem.kind(), ty::Int(_)),
InvalidMonomorphization::InvalidBitmask {
InvalidMonomorphization::ThirdArgElementType {
span,
name,
mask_ty,
expected_int_bits,
expected_bytes
expected_element: values_elem,
third_arg: mask_ty,
}
);

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/simd/masked-load-store-build-fail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() {
arr.as_ptr(),
default
);
//~^^^^^ ERROR invalid bitmask `Simd<u8, 4>`, expected `u8` or `[u8; 1]`
//~^^^^^ ERROR expected element type `u8` of third argument `Simd<u8, 4>` to be a signed integer type

simd_masked_store(
Simd([-1i8; 4]),
Expand Down Expand Up @@ -69,6 +69,6 @@ fn main() {
arr.as_mut_ptr(),
Simd([5u8; 4])
);
//~^^^^^ ERROR invalid bitmask `Simd<u32, 4>`, expected `u8` or `[u8; 1]
//~^^^^^ ERROR expected element type `u8` of third argument `Simd<u32, 4>` to be a signed integer type
}
}
4 changes: 2 additions & 2 deletions tests/ui/simd/masked-load-store-build-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LL | | Simd::<u32, 4>([9; 4])
LL | | );
| |_________^

error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: invalid bitmask `Simd<u8, 4>`, expected `u8` or `[u8; 1]`
error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected element type `u8` of third argument `Simd<u8, 4>` to be a signed integer type
--> $DIR/masked-load-store-build-fail.rs:39:9
|
LL | / simd_masked_load(
Expand Down Expand Up @@ -68,7 +68,7 @@ LL | | Simd([5u8; 2])
LL | | );
| |_________^

error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: invalid bitmask `Simd<u32, 4>`, expected `u8` or `[u8; 1]`
error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected element type `u8` of third argument `Simd<u32, 4>` to be a signed integer type
--> $DIR/masked-load-store-build-fail.rs:67:9
|
LL | / simd_masked_store(
Expand Down

0 comments on commit e271119

Please sign in to comment.