@@ -1599,10 +1599,31 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
15991599
16001600 pub fn vector_select ( & mut self , cond : RValue < ' gcc > , then_val : RValue < ' gcc > , else_val : RValue < ' gcc > ) -> RValue < ' gcc > {
16011601 // cond is a vector of integers, not of bools.
1602- let cond_type = cond. get_type ( ) ;
1603- let vector_type = cond_type. unqualified ( ) . dyncast_vector ( ) . expect ( "vector type" ) ;
1602+ let vector_type = cond. get_type ( ) . unqualified ( ) . dyncast_vector ( ) . expect ( "vector type" ) ;
16041603 let num_units = vector_type. get_num_units ( ) ;
16051604 let element_type = vector_type. get_element_type ( ) ;
1605+
1606+ #[ cfg( feature="master" ) ]
1607+ let ( cond, element_type) = {
1608+ let then_val_vector_type = then_val. get_type ( ) . dyncast_vector ( ) . expect ( "vector type" ) ;
1609+ let then_val_element_type = then_val_vector_type. get_element_type ( ) ;
1610+ let then_val_element_size = then_val_element_type. get_size ( ) ;
1611+
1612+ // NOTE: the mask needs to be of the same size as the other arguments in order for the &
1613+ // operation to work.
1614+ if then_val_element_size != element_type. get_size ( ) {
1615+ let new_element_type = self . type_ix ( then_val_element_size as u64 * 8 ) ;
1616+ let new_vector_type = self . context . new_vector_type ( new_element_type, num_units as u64 ) ;
1617+ let cond = self . context . convert_vector ( None , cond, new_vector_type) ;
1618+ ( cond, new_element_type)
1619+ }
1620+ else {
1621+ ( cond, element_type)
1622+ }
1623+ } ;
1624+
1625+ let cond_type = cond. get_type ( ) ;
1626+
16061627 let zeros = vec ! [ self . context. new_rvalue_zero( element_type) ; num_units] ;
16071628 let zeros = self . context . new_rvalue_from_vector ( None , cond_type, & zeros) ;
16081629
0 commit comments