@@ -170,9 +170,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
170
170
if a_type. is_vector ( ) {
171
171
// Vector types need to be bitcast.
172
172
// 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 ) ;
174
174
} else {
175
- b = self . context . new_cast ( self . ___location , b, a . get_type ( ) ) ;
175
+ b = self . context . new_cast ( self . ___location , b, a_type ) ;
176
176
}
177
177
}
178
178
self . context . new_binary_op ( self . ___location , operation, a_type, a, b)
@@ -219,13 +219,22 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
219
219
operation_name : & str ,
220
220
signed : bool ,
221
221
a : RValue < ' gcc > ,
222
- b : RValue < ' gcc > ,
222
+ mut b : RValue < ' gcc > ,
223
223
) -> RValue < ' gcc > {
224
224
let a_type = a. get_type ( ) ;
225
225
let b_type = b. get_type ( ) ;
226
226
if ( self . is_native_int_type_or_bool ( a_type) && self . is_native_int_type_or_bool ( b_type) )
227
227
|| ( a_type. is_vector ( ) && b_type. is_vector ( ) )
228
228
{
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
+ }
229
238
self . context . new_binary_op ( self . ___location , operation, a_type, a, b)
230
239
} else {
231
240
debug_assert ! ( a_type. dyncast_array( ) . is_some( ) ) ;
@@ -626,14 +635,17 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
626
635
}
627
636
}
628
637
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 > {
630
639
let a_type = a. get_type ( ) ;
631
640
let b_type = b. get_type ( ) ;
632
641
if a_type. is_vector ( ) && b_type. is_vector ( ) {
633
642
let b = self . bitcast_if_needed ( b, a_type) ;
634
643
a ^ b
635
644
} else if self . is_native_int_type_or_bool ( a_type) && self . is_native_int_type_or_bool ( b_type)
636
645
{
646
+ if !a_type. is_compatible_with ( b_type) {
647
+ b = self . context . new_cast ( self . ___location , b, a_type) ;
648
+ }
637
649
a ^ b
638
650
} else {
639
651
self . concat_low_high_rvalues (
0 commit comments