From d7d820fc47a5987566550ef9ede2ea18b0d1ff05 Mon Sep 17 00:00:00 2001 From: Andy Sadler Date: Wed, 7 Sep 2022 21:32:34 -0500 Subject: [PATCH] simd: impl extract_element for vector types This fixes some tests that needed vector element extraction. Signed-off-by: Andy Sadler --- failing-ui-tests.txt | 2 -- failing-ui-tests12.txt | 1 + src/builder.rs | 15 +++++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/failing-ui-tests.txt b/failing-ui-tests.txt index fc6dcfc7bc7..7fe9e084940 100644 --- a/failing-ui-tests.txt +++ b/failing-ui-tests.txt @@ -30,12 +30,10 @@ src/test/ui/sepcomp/sepcomp-extern.rs src/test/ui/sepcomp/sepcomp-fns-backwards.rs src/test/ui/sepcomp/sepcomp-fns.rs src/test/ui/sepcomp/sepcomp-statics.rs -src/test/ui/simd/generics.rs src/test/ui/simd/intrinsic/float-math-pass.rs src/test/ui/simd/intrinsic/generic-arithmetic-pass.rs src/test/ui/simd/intrinsic/generic-as.rs src/test/ui/simd/intrinsic/generic-bitmask-pass.rs -src/test/ui/simd/intrinsic/generic-comparison-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 diff --git a/failing-ui-tests12.txt b/failing-ui-tests12.txt index e7952f52412..7826875f04e 100644 --- a/failing-ui-tests12.txt +++ b/failing-ui-tests12.txt @@ -12,6 +12,7 @@ src/test/ui/simd/intrinsic/float-minmax-pass.rs src/test/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs src/test/ui/simd/intrinsic/generic-cast-pass.rs 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/inlining-issue67557-ice.rs diff --git a/src/builder.rs b/src/builder.rs index 52a4854aca3..95080e024fc 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1059,8 +1059,19 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { unimplemented!(); } - fn extract_element(&mut self, _vec: RValue<'gcc>, _idx: RValue<'gcc>) -> RValue<'gcc> { - unimplemented!(); + #[cfg(feature="master")] + fn extract_element(&mut self, vec: RValue<'gcc>, idx: RValue<'gcc>) -> RValue<'gcc> { + self.context.new_vector_access(None, vec, idx).to_rvalue() + } + + #[cfg(not(feature="master"))] + fn extract_element(&mut self, vec: RValue<'gcc>, idx: RValue<'gcc>) -> RValue<'gcc> { + let vector_type = vec.get_type().unqualified().dyncast_vector().expect("Called extract_element on a non-vector type"); + let element_type = vector_type.get_element_type(); + let vec_num_units = vector_type.get_num_units(); + let array_type = self.context.new_array_type(None, element_type, vec_num_units as i32); + let array = self.context.new_bitcast(None, vec, array_type).to_rvalue(); + self.context.new_array_access(None, array, idx).to_rvalue() } fn vector_splat(&mut self, _num_elts: usize, _elt: RValue<'gcc>) -> RValue<'gcc> {