Skip to content

Commit 863cfb2

Browse files
Fix FIXME in Builder::and and Builder::or impls (rust-lang#101)
* impl bitwise and & or
1 parent 6693595 commit 863cfb2

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/builder.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -605,22 +605,17 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
605605
}
606606

607607
fn and(&mut self, a: RValue<'gcc>, mut b: RValue<'gcc>) -> RValue<'gcc> {
608-
// FIXME(antoyo): hack by putting the result in a variable to workaround this bug:
609-
// https://gcc.gnu.org/bugzilla//show_bug.cgi?id=95498
610608
if a.get_type() != b.get_type() {
611609
b = self.context.new_cast(None, b, a.get_type());
612610
}
613-
let res = self.current_func().new_local(None, b.get_type(), "andResult");
614-
self.llbb().add_assignment(None, res, a & b);
615-
res.to_rvalue()
611+
a & b
616612
}
617613

618-
fn or(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
619-
// FIXME(antoyo): hack by putting the result in a variable to workaround this bug:
620-
// https://gcc.gnu.org/bugzilla//show_bug.cgi?id=95498
621-
let res = self.current_func().new_local(None, b.get_type(), "orResult");
622-
self.llbb().add_assignment(None, res, a | b);
623-
res.to_rvalue()
614+
fn or(&mut self, a: RValue<'gcc>, mut b: RValue<'gcc>) -> RValue<'gcc> {
615+
if a.get_type() != b.get_type() {
616+
b = self.context.new_cast(None, b, a.get_type());
617+
}
618+
a | b
624619
}
625620

626621
fn xor(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {

0 commit comments

Comments
 (0)