Skip to content

Commit 931e6bd

Browse files
committed
Fix simd_gather
1 parent f3e7c3d commit 931e6bd

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

src/builder.rs

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,18 +1926,35 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
19261926
self.int_type
19271927
};
19281928

1929-
let vector_type =
1930-
mask.get_type().dyncast_vector().expect("simd_shuffle mask should be of vector type");
1931-
let mask_num_units = vector_type.get_num_units();
1932-
let mut mask_elements = vec![];
1933-
for i in 0..mask_num_units {
1934-
let index = self.context.new_rvalue_from_long(self.cx.type_u32(), i as _);
1935-
mask_elements.push(self.context.new_cast(
1936-
self.location,
1937-
self.extract_element(mask, index).to_rvalue(),
1938-
mask_element_type,
1939-
));
1940-
}
1929+
// NOTE: this condition is needed because we call shuffle_vector in the implementation of
1930+
// simd_gather.
1931+
let mut mask_elements = if let Some(vector_type) = mask.get_type().dyncast_vector() {
1932+
let mask_num_units = vector_type.get_num_units();
1933+
let mut mask_elements = vec![];
1934+
for i in 0..mask_num_units {
1935+
let index = self.context.new_rvalue_from_long(self.cx.type_u32(), i as _);
1936+
mask_elements.push(self.context.new_cast(
1937+
self.location,
1938+
self.extract_element(mask, index).to_rvalue(),
1939+
mask_element_type,
1940+
));
1941+
}
1942+
mask_elements
1943+
} else {
1944+
let struct_type = mask.get_type().is_struct().expect("mask should be of struct type");
1945+
let mask_num_units = struct_type.get_field_count();
1946+
let mut mask_elements = vec![];
1947+
for i in 0..mask_num_units {
1948+
let field = struct_type.get_field(i as i32);
1949+
mask_elements.push(self.context.new_cast(
1950+
self.location,
1951+
mask.access_field(self.location, field).to_rvalue(),
1952+
mask_element_type,
1953+
));
1954+
}
1955+
mask_elements
1956+
};
1957+
let mask_num_units = mask_elements.len();
19411958

19421959
// NOTE: the mask needs to be the same length as the input vectors, so add the missing
19431960
// elements in the mask if needed.

tests/failing-ui-tests.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,5 @@ tests/ui/codegen/equal-pointers-unequal/strict-provenance/segfault.rs
122122
tests/ui/codegen/equal-pointers-unequal/strict-provenance/zero.rs
123123
tests/ui/sanitizer/cfi/sized-associated-ty.rs
124124
tests/ui/sanitizer/cfi/can-reveal-opaques.rs
125+
tests/ui/sanitizer/cfi/transparent-has-regions.rs
126+
tests/ui/simd/simd-bitmask-notpow2.rs

0 commit comments

Comments
 (0)