Skip to content

Commit 5ac9bee

Browse files
committed
fix tests/ui/simd/issue-89193.rs and mark as passing
Work around an issue where usize and isize can sometimes (but not always) get canonicalized to their corresponding integer type. This causes shuffle_vector to panic, since the types of the vectors it got passed aren't the same. Also insert a cast on the mask element, since we might get passed a signed integer of any size, not just i32. For now, we always cast to i32. Signed-off-by: Andy Sadler <andrewsadler122@gmail.com>
1 parent e69f125 commit 5ac9bee

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/intrinsic/simd.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
710710
};
711711
let elem_type = vector_type.dyncast_vector().expect("vector type").get_element_type();
712712

713-
let mut values = vec![];
713+
let mut values = Vec::with_capacity(in_len as usize);
714714
for i in 0..in_len {
715715
let index = bx.context.new_rvalue_from_long(bx.i32_type, i as i64);
716716
let int = bx.context.new_vector_access(None, pointers, index).to_rvalue();
@@ -723,19 +723,26 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
723723

724724
let vector = bx.context.new_rvalue_from_vector(None, vector_type, &values);
725725

726-
let mut mask_types = vec![];
727-
let mut mask_values = vec![];
726+
let mut mask_types = Vec::with_capacity(in_len as usize);
727+
let mut mask_values = Vec::with_capacity(in_len as usize);
728728
for i in 0..in_len {
729729
let index = bx.context.new_rvalue_from_long(bx.i32_type, i as i64);
730730
mask_types.push(bx.context.new_field(None, bx.i32_type, "m"));
731731
let mask_value = bx.context.new_vector_access(None, mask, index).to_rvalue();
732-
let masked = bx.context.new_rvalue_from_int(bx.i32_type, in_len as i32) & mask_value;
732+
let mask_value_cast = bx.context.new_cast(None, mask_value, bx.i32_type);
733+
let masked = bx.context.new_rvalue_from_int(bx.i32_type, in_len as i32) & mask_value_cast;
733734
let value = index + masked;
734735
mask_values.push(value);
735736
}
736737
let mask_type = bx.context.new_struct_type(None, "mask_type", &mask_types);
737738
let mask = bx.context.new_struct_constructor(None, mask_type.as_type(), None, &mask_values);
738739

740+
// FIXME(antoyo): We sometimes need to bitcast here, since usize/isize sometimes (but not
741+
// always) get canonicalized to their corresponding integer type (i.e. uint64_t/int64_t on
742+
// 64-bit platforms). This causes the shuffle_vector call below to panic, since the types
743+
// of the two vectors aren't the same. This is a workaround for now.
744+
let vector = bx.bitcast_if_needed(vector, default.get_type());
745+
739746
if invert {
740747
bx.shuffle_vector(vector, default, mask)
741748
} else {

tests/failing-ui-tests.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ tests/ui/rfcs/rfc-1857-stabilize-drop-order/drop-order.rs
4848
tests/ui/rfcs/rfc-2091-track-caller/std-panic-locations.rs
4949
tests/ui/simd/issue-17170.rs
5050
tests/ui/simd/issue-39720.rs
51-
tests/ui/simd/issue-89193.rs
5251
tests/ui/statics/issue-91050-1.rs
5352
tests/ui/statics/issue-91050-2.rs
5453
tests/ui/alloc-error/default-alloc-error-hook.rs

0 commit comments

Comments
 (0)