Skip to content

Commit 2342414

Browse files
authored
Merge pull request rust-lang#213 from rust-lang/fix/bitcast-wrong-size
Fix bitcast to a type of a different size
2 parents 866f9c5 + 45ec5f2 commit 2342414

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

src/builder.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,22 +1364,17 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
13641364
vector_elements.push(self.context.new_rvalue_zero(mask_element_type));
13651365
}
13661366

1367-
let array_type = self.context.new_array_type(None, element_type, vec_num_units as i32);
13681367
let result_type = self.context.new_vector_type(element_type, mask_num_units as u64);
13691368
let (v1, v2) =
13701369
if vec_num_units < mask_num_units {
13711370
// NOTE: the mask needs to be the same length as the input vectors, so join the 2
13721371
// vectors and create a dummy second vector.
1373-
// TODO(antoyo): switch to using new_vector_access.
1374-
let array = self.context.new_bitcast(None, v1, array_type);
13751372
let mut elements = vec![];
13761373
for i in 0..vec_num_units {
1377-
elements.push(self.context.new_array_access(None, array, self.context.new_rvalue_from_int(self.int_type, i as i32)).to_rvalue());
1374+
elements.push(self.context.new_vector_access(None, v1, self.context.new_rvalue_from_int(self.int_type, i as i32)).to_rvalue());
13781375
}
1379-
// TODO(antoyo): switch to using new_vector_access.
1380-
let array = self.context.new_bitcast(None, v2, array_type);
13811376
for i in 0..(mask_num_units - vec_num_units) {
1382-
elements.push(self.context.new_array_access(None, array, self.context.new_rvalue_from_int(self.int_type, i as i32)).to_rvalue());
1377+
elements.push(self.context.new_vector_access(None, v2, self.context.new_rvalue_from_int(self.int_type, i as i32)).to_rvalue());
13831378
}
13841379
let v1 = self.context.new_rvalue_from_vector(None, result_type, &elements);
13851380
let zero = self.context.new_rvalue_zero(element_type);
@@ -1399,10 +1394,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
13991394
// NOTE: if padding was added, only select the number of elements of the masks to
14001395
// remove that padding in the result.
14011396
let mut elements = vec![];
1402-
// TODO(antoyo): switch to using new_vector_access.
1403-
let array = self.context.new_bitcast(None, result, array_type);
14041397
for i in 0..mask_num_units {
1405-
elements.push(self.context.new_array_access(None, array, self.context.new_rvalue_from_int(self.int_type, i as i32)).to_rvalue());
1398+
elements.push(self.context.new_vector_access(None, result, self.context.new_rvalue_from_int(self.int_type, i as i32)).to_rvalue());
14061399
}
14071400
self.context.new_rvalue_from_vector(None, result_type, &elements)
14081401
}

0 commit comments

Comments
 (0)