mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
fix: emit vector instead of scalar u1_zero in shl_with_overflow logic
This commit is contained in:
parent
4ec421372f
commit
277e4a8337
2 changed files with 3 additions and 4 deletions
|
|
@ -15620,7 +15620,6 @@ fn zirOverflowArithmetic(
|
||||||
// If either of the arguments is undefined, IB is possible and we return an error.
|
// If either of the arguments is undefined, IB is possible and we return an error.
|
||||||
// If lhs is zero, the result is zero and no overflow occurred.
|
// If lhs is zero, the result is zero and no overflow occurred.
|
||||||
// If rhs is zero, the result is lhs and no overflow occurred.
|
// If rhs is zero, the result is lhs and no overflow occurred.
|
||||||
// Oterhwise if either of the arguments is undefined, both results are undefined.
|
|
||||||
const scalar_ty = lhs_ty.scalarType(zcu);
|
const scalar_ty = lhs_ty.scalarType(zcu);
|
||||||
if (maybe_rhs_val) |rhs_val| {
|
if (maybe_rhs_val) |rhs_val| {
|
||||||
if (maybe_lhs_val) |lhs_val| {
|
if (maybe_lhs_val) |lhs_val| {
|
||||||
|
|
@ -15661,7 +15660,7 @@ fn zirOverflowArithmetic(
|
||||||
.lt => return sema.failWithNegativeShiftAmount(block, rhs_src, rhs_elem, elem_idx),
|
.lt => return sema.failWithNegativeShiftAmount(block, rhs_src, rhs_elem, elem_idx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!any_positive) break :result .{ .overflow_bit = .zero_u1, .inst = lhs };
|
if (!any_positive) break :result .{ .overflow_bit = try pt.aggregateSplatValue(overflow_ty, .zero_u1), .inst = lhs };
|
||||||
},
|
},
|
||||||
else => unreachable,
|
else => unreachable,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1895,10 +1895,10 @@ fn intShlWithOverflow(
|
||||||
const info = lhs_ty.intInfo(zcu);
|
const info = lhs_ty.intInfo(zcu);
|
||||||
|
|
||||||
var lhs_space: Value.BigIntSpace = undefined;
|
var lhs_space: Value.BigIntSpace = undefined;
|
||||||
const lhs_bigint = lhs.toBigInt(&lhs_space, zcu);
|
const lhs_bigint = try lhs.toBigIntSema(&lhs_space, pt);
|
||||||
|
|
||||||
const shift_amt: usize = @intCast(try rhs.toUnsignedIntSema(pt));
|
const shift_amt: usize = @intCast(try rhs.toUnsignedIntSema(pt));
|
||||||
if (shift_amt >= lhs_ty.intInfo(zcu).bits) {
|
if (shift_amt >= info.bits) {
|
||||||
return sema.failWithTooLargeShiftAmount(block, lhs_ty, rhs, rhs_src, vec_idx);
|
return sema.failWithTooLargeShiftAmount(block, lhs_ty, rhs, rhs_src, vec_idx);
|
||||||
}
|
}
|
||||||
var result_bigint = try intShlInner(sema, lhs_bigint, shift_amt);
|
var result_bigint = try intShlInner(sema, lhs_bigint, shift_amt);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue