Skip to content

Commit ad5aff5

Browse files
committed
trans: Do not depend on having Expr's around for generic_simd_intrinsic.
1 parent 5255a31 commit ad5aff5

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/librustc_trans/trans/intrinsic.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,22 +1502,26 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
15021502

15031503
let total_len = in_len as u64 * 2;
15041504

1505-
let vector = match args {
1506-
Some(args) => &args[2],
1507-
None => bcx.sess().span_bug(span,
1508-
"intrinsic call with unexpected argument shape"),
1509-
};
1510-
let vector = match consts::const_expr(bcx.ccx(), vector, substs, None,
1511-
consts::TrueConst::Yes, // this should probably help simd error reporting
1512-
) {
1513-
Ok((vector, _)) => vector,
1514-
Err(err) => bcx.sess().span_fatal(span, &err.description()),
1505+
let (vector, indirect) = match args {
1506+
Some(args) => {
1507+
match consts::const_expr(bcx.ccx(), &args[2], substs, None,
1508+
// this should probably help simd error reporting
1509+
consts::TrueConst::Yes) {
1510+
Ok((vector, _)) => (vector, false),
1511+
Err(err) => bcx.sess().span_fatal(span, &err.description()),
1512+
}
1513+
}
1514+
None => (llargs[2], !type_is_immediate(bcx.ccx(), arg_tys[2]))
15151515
};
15161516

15171517
let indices: Option<Vec<_>> = (0..n)
15181518
.map(|i| {
15191519
let arg_idx = i;
1520-
let val = const_get_elt(vector, &[i as libc::c_uint]);
1520+
let val = if indirect {
1521+
Load(bcx, StructGEP(bcx, vector, i))
1522+
} else {
1523+
const_get_elt(vector, &[i as libc::c_uint])
1524+
};
15211525
let c = const_to_opt_uint(val);
15221526
match c {
15231527
None => {

0 commit comments

Comments
 (0)