diff options
| author | Fisher Darling <fdarlingco@gmail.com> | 2021-10-12 09:39:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-12 12:39:14 -0400 |
| commit | 863cfb2d635188a42114a3f7578acbfa645f48ae (patch) | |
| tree | 2e59401783cafa9c3d9f73b7edc514c31bcea766 | |
| parent | 669359530ec3dcfa5c1cc8d9afd80813a246f09b (diff) | |
| download | rust-863cfb2d635188a42114a3f7578acbfa645f48ae.tar.gz rust-863cfb2d635188a42114a3f7578acbfa645f48ae.zip | |
Fix FIXME in `Builder::and` and `Builder::or` impls (#101)
* impl bitwise and & or
| -rw-r--r-- | src/builder.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/builder.rs b/src/builder.rs index ac908418ee4..0ccb38b8047 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -605,22 +605,17 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> { } fn and(&mut self, a: RValue<'gcc>, mut b: RValue<'gcc>) -> RValue<'gcc> { - // FIXME(antoyo): hack by putting the result in a variable to workaround this bug: - // https://gcc.gnu.org/bugzilla//show_bug.cgi?id=95498 if a.get_type() != b.get_type() { b = self.context.new_cast(None, b, a.get_type()); } - let res = self.current_func().new_local(None, b.get_type(), "andResult"); - self.llbb().add_assignment(None, res, a & b); - res.to_rvalue() + a & b } - fn or(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { - // FIXME(antoyo): hack by putting the result in a variable to workaround this bug: - // https://gcc.gnu.org/bugzilla//show_bug.cgi?id=95498 - let res = self.current_func().new_local(None, b.get_type(), "orResult"); - self.llbb().add_assignment(None, res, a | b); - res.to_rvalue() + fn or(&mut self, a: RValue<'gcc>, mut b: RValue<'gcc>) -> RValue<'gcc> { + if a.get_type() != b.get_type() { + b = self.context.new_cast(None, b, a.get_type()); + } + a | b } fn xor(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> { |
