Skip to content

Commit 85fa75c

Browse files
Add shl and shr missing casts
1 parent 2df8185 commit 85fa75c

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ impl<'b, 'tcx> CodegenCx<'b, 'tcx> {
624624
let mut name = String::with_capacity(prefix.len() + 6);
625625
name.push_str(prefix);
626626
name.push('.');
627-
base_n::push_str(idx as u128, base_n::ALPHANUMERIC_ONLY, &mut name);
627+
name.push_str(&(idx as u64).to_base(ALPHANUMERIC_ONLY));
628628
name
629629
}
630630
}

src/int.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,17 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
8181
let b = self.context.new_cast(self.location, b, a_type);
8282
a >> b
8383
} else {
84-
a >> b
84+
let a_size = a_type.get_size();
85+
let b_size = b_type.get_size();
86+
if a_size > b_size {
87+
let b = self.context.new_cast(self.location, b, a_type);
88+
a >> b
89+
} else if a_size < b_size {
90+
let a = self.context.new_cast(self.location, a, b_type);
91+
a >> b
92+
} else {
93+
a >> b
94+
}
8595
}
8696
} else if a_type.is_vector() && a_type.is_vector() {
8797
a >> b
@@ -636,7 +646,17 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
636646
let b = self.context.new_cast(self.location, b, a_type);
637647
a << b
638648
} else {
639-
a << b
649+
let a_size = a_type.get_size();
650+
let b_size = b_type.get_size();
651+
if a_size > b_size {
652+
let b = self.context.new_cast(self.location, b, a_type);
653+
a << b
654+
} else if a_size < b_size {
655+
let a = self.context.new_cast(self.location, a, b_type);
656+
a << b
657+
} else {
658+
a << b
659+
}
640660
}
641661
} else if a_type.is_vector() && a_type.is_vector() {
642662
a << b

0 commit comments

Comments
 (0)