Skip to content

Commit

Permalink
Fix simd_select
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Oct 9, 2022
1 parent e5ce7a9 commit 173db39
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 0 additions & 1 deletion failing-ui-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ src/test/ui/sepcomp/sepcomp-statics.rs
src/test/ui/simd/intrinsic/generic-arithmetic-pass.rs
src/test/ui/simd/intrinsic/generic-bitmask-pass.rs
src/test/ui/simd/intrinsic/generic-gather-pass.rs
src/test/ui/simd/intrinsic/generic-select-pass.rs
src/test/ui/simd/issue-17170.rs
src/test/ui/simd/issue-39720.rs
src/test/ui/simd/issue-85915-simd-ptrs.rs
Expand Down
1 change: 1 addition & 0 deletions failing-ui-tests12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ src/test/ui/simd/intrinsic/generic-cast-pointer-width.rs
src/test/ui/simd/intrinsic/generic-comparison-pass.rs
src/test/ui/simd/intrinsic/generic-elements-pass.rs
src/test/ui/simd/intrinsic/generic-reduction-pass.rs
src/test/ui/simd/intrinsic/generic-select-pass.rs
src/test/ui/simd/intrinsic/inlining-issue67557-ice.rs
src/test/ui/simd/intrinsic/inlining-issue67557.rs
src/test/ui/simd/monomorphize-shuffle-index.rs
Expand Down
25 changes: 23 additions & 2 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1599,10 +1599,31 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {

pub fn vector_select(&mut self, cond: RValue<'gcc>, then_val: RValue<'gcc>, else_val: RValue<'gcc>) -> RValue<'gcc> {
// cond is a vector of integers, not of bools.
let cond_type = cond.get_type();
let vector_type = cond_type.unqualified().dyncast_vector().expect("vector type");
let vector_type = cond.get_type().unqualified().dyncast_vector().expect("vector type");
let num_units = vector_type.get_num_units();
let element_type = vector_type.get_element_type();

#[cfg(feature="master")]
let (cond, element_type) = {
let then_val_vector_type = then_val.get_type().dyncast_vector().expect("vector type");
let then_val_element_type = then_val_vector_type.get_element_type();
let then_val_element_size = then_val_element_type.get_size();

// NOTE: the mask needs to be of the same size as the other arguments in order for the &
// operation to work.
if then_val_element_size != element_type.get_size() {
let new_element_type = self.type_ix(then_val_element_size as u64 * 8);
let new_vector_type = self.context.new_vector_type(new_element_type, num_units as u64);
let cond = self.context.convert_vector(None, cond, new_vector_type);
(cond, new_element_type)
}
else {
(cond, element_type)
}
};

let cond_type = cond.get_type();

let zeros = vec![self.context.new_rvalue_zero(element_type); num_units];
let zeros = self.context.new_rvalue_from_vector(None, cond_type, &zeros);

Expand Down

0 comments on commit 173db39

Please sign in to comment.