Skip to content

Commit 5739ed1

Browse files
committed
trans: Do not depend on having Expr's around for generic_simd_intrinsic.
1 parent 7912f94 commit 5739ed1

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
@@ -1506,22 +1506,26 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a>
15061506

15071507
let total_len = in_len as u64 * 2;
15081508

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

15211521
let indices: Option<Vec<_>> = (0..n)
15221522
.map(|i| {
15231523
let arg_idx = i;
1524-
let val = const_get_elt(vector, &[i as libc::c_uint]);
1524+
let val = if indirect {
1525+
Load(bcx, StructGEP(bcx, vector, i))
1526+
} else {
1527+
const_get_elt(vector, &[i as libc::c_uint])
1528+
};
15251529
let c = const_to_opt_uint(val);
15261530
match c {
15271531
None => {

0 commit comments

Comments
 (0)