diff options
| author | antoyo <antoyo@users.noreply.github.com> | 2023-12-19 13:00:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-19 13:00:35 -0500 |
| commit | db494375ab995602fc23ee467fa44f318864f250 (patch) | |
| tree | 869bd567e1a184e93b584729bc06b5d153a4b86c /src/builder.rs | |
| parent | 0a67e9cd60a23f8300f35880d7aac79d98f7294f (diff) | |
| parent | 17b2c46c8896adf07ae8f70b0d8b70227b5f4c71 (diff) | |
| download | rust-db494375ab995602fc23ee467fa44f318864f250.tar.gz rust-db494375ab995602fc23ee467fa44f318864f250.zip | |
Merge pull request #382 from sadlerap/impl-generic-arithmetic-pass
simd: implement missing intrinsics from simd/generic-arithmetic-pass.rs
Diffstat (limited to 'src/builder.rs')
| -rw-r--r-- | src/builder.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/builder.rs b/src/builder.rs index b8a8c144dc9..4ae56a41e52 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -606,12 +606,29 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { // ../../../gcc/gcc/cfgexpand.cc:6069 // 0x7f0101bf9194 execute // ../../../gcc/gcc/cfgexpand.cc:6795 - if a.get_type().is_compatible_with(self.cx.float_type) { + let a_type = a.get_type(); + let a_type_unqualified = a_type.unqualified(); + if a_type.is_compatible_with(self.cx.float_type) { let fmodf = self.context.get_builtin_function("fmodf"); // FIXME(antoyo): this seems to produce the wrong result. return self.context.new_call(None, fmodf, &[a, b]); } - assert_eq!(a.get_type().unqualified(), self.cx.double_type); + else if let Some(vector_type) = a_type_unqualified.dyncast_vector() { + assert_eq!(a_type_unqualified, b.get_type().unqualified()); + + let num_units = vector_type.get_num_units(); + let new_elements: Vec<_> = (0..num_units) + .map(|i| { + let index = self.context.new_rvalue_from_long(self.cx.type_u32(), i as _); + let x = self.extract_element(a, index).to_rvalue(); + let y = self.extract_element(b, index).to_rvalue(); + self.frem(x, y) + }) + .collect(); + + return self.context.new_rvalue_from_vector(None, a_type, &new_elements) + } + assert_eq!(a_type_unqualified, self.cx.double_type); let fmod = self.context.get_builtin_function("fmod"); return self.context.new_call(None, fmod, &[a, b]); |
