Skip to content

Commit b4c4bbe

Browse files
Rollup merge of #156202 - maurer:splat, r=nikic
llvm: Use correct type for splat mask After llvm/llvm-project#195486 , LLVM has explicit handling for null pointers in simd operations instead of using special handling based on zeroes. This causes LLVM with asserts enabled to detect an improperly typed mask passed to splat (if the output vector does not have i32 elements), and can cause SIGSEGV in more complex cases with asserts disabled. @rustbot label: +llvm-main r? @durin42
2 parents 8ad1708 + 3c83d3a commit b4c4bbe

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
20862086
}
20872087

20882088
if name == sym::simd_splat {
2089-
let (_out_len, out_ty) = require_simd!(ret_ty, SimdReturn);
2089+
let (out_len, out_ty) = require_simd!(ret_ty, SimdReturn);
20902090

20912091
require!(
20922092
args[0].layout.ty == out_ty,
@@ -2105,7 +2105,8 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
21052105

21062106
// `shufflevector <N x elem> v0, <N x elem> poison, <N x i32> zeroinitializer`
21072107
// The masks is all zeros, so this splats lane 0 (which has our element in it).
2108-
let splat = bx.shuffle_vector(v0, poison_vec, bx.const_null(llret_ty));
2108+
let mask_ty = bx.type_vector(bx.type_i32(), out_len);
2109+
let splat = bx.shuffle_vector(v0, poison_vec, bx.const_null(mask_ty));
21092110

21102111
return Ok(splat);
21112112
}

0 commit comments

Comments
 (0)