Skip to content

Commit 9ea1827

Browse files
committed
Fix sysroot compilation in release mode
1 parent a5bd9d6 commit 9ea1827

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/int.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
170170
if a_type.is_vector() {
171171
// Vector types need to be bitcast.
172172
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
173-
b = self.context.new_bitcast(self.___location, b, a.get_type());
173+
b = self.context.new_bitcast(self.___location, b, a_type);
174174
} else {
175-
b = self.context.new_cast(self.___location, b, a.get_type());
175+
b = self.context.new_cast(self.___location, b, a_type);
176176
}
177177
}
178178
self.context.new_binary_op(self.___location, operation, a_type, a, b)
@@ -219,13 +219,22 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
219219
operation_name: &str,
220220
signed: bool,
221221
a: RValue<'gcc>,
222-
b: RValue<'gcc>,
222+
mut b: RValue<'gcc>,
223223
) -> RValue<'gcc> {
224224
let a_type = a.get_type();
225225
let b_type = b.get_type();
226226
if (self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type))
227227
|| (a_type.is_vector() && b_type.is_vector())
228228
{
229+
if !a_type.is_compatible_with(b_type) {
230+
if a_type.is_vector() {
231+
// Vector types need to be bitcast.
232+
// TODO(antoyo): perhaps use __builtin_convertvector for vector casting.
233+
b = self.context.new_bitcast(self.___location, b, a_type);
234+
} else {
235+
b = self.context.new_cast(self.___location, b, a_type);
236+
}
237+
}
229238
self.context.new_binary_op(self.___location, operation, a_type, a, b)
230239
} else {
231240
debug_assert!(a_type.dyncast_array().is_some());
@@ -626,14 +635,17 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
626635
}
627636
}
628637

629-
pub fn gcc_xor(&self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
638+
pub fn gcc_xor(&self, a: RValue<'gcc>, mut b: RValue<'gcc>) -> RValue<'gcc> {
630639
let a_type = a.get_type();
631640
let b_type = b.get_type();
632641
if a_type.is_vector() && b_type.is_vector() {
633642
let b = self.bitcast_if_needed(b, a_type);
634643
a ^ b
635644
} else if self.is_native_int_type_or_bool(a_type) && self.is_native_int_type_or_bool(b_type)
636645
{
646+
if !a_type.is_compatible_with(b_type) {
647+
b = self.context.new_cast(self.___location, b, a_type);
648+
}
637649
a ^ b
638650
} else {
639651
self.concat_low_high_rvalues(

0 commit comments

Comments
 (0)