@@ -10078,13 +10078,21 @@ fn intCast(
1007810078 if (actual_info.signedness == .signed) {
1007910079 // Reinterpret the sign-bit as part of the value. This will make
1008010080 // negative differences (`operand` > `dest_max`) appear too big.
10081- const unsigned_operand_ty = try mod.intType(.unsigned, actual_bits);
10081+ const unsigned_scalar_operand_ty = try mod.intType(.unsigned, actual_bits);
10082+ const unsigned_operand_ty = if (is_vector) try mod.vectorType(.{
10083+ .len = dest_ty.vectorLen(mod),
10084+ .child = unsigned_scalar_operand_ty.toIntern(),
10085+ }) else unsigned_scalar_operand_ty;
1008210086 const diff_unsigned = try block.addBitCast(unsigned_operand_ty, diff);
1008310087
1008410088 // If the destination type is signed, then we need to double its
1008510089 // range to account for negative values.
1008610090 const dest_range_val = if (wanted_info.signedness == .signed) range_val: {
10087- const one = try mod.intValue(unsigned_operand_ty, 1);
10091+ const one_scalar = try mod.intValue(unsigned_scalar_operand_ty, 1);
10092+ const one = if (is_vector) (try mod.intern(.{ .aggregate = .{
10093+ .ty = unsigned_operand_ty.toIntern(),
10094+ .storage = .{ .repeated_elem = one_scalar.toIntern() },
10095+ } })).toValue() else one_scalar;
1008810096 const range_minus_one = try dest_max_val.shl(one, unsigned_operand_ty, sema.arena, mod);
1008910097 break :range_val try sema.intAdd(range_minus_one, one, unsigned_operand_ty, undefined);
1009010098 } else try mod.getCoerced(dest_max_val, unsigned_operand_ty);
0 commit comments