authorgravatar for justus@klausecker.deJustus Klausecker <justus@klausecker.de> 2025-08-09 02:33:25+02:00
committergravatar for justus@klausecker.deJustus Klausecker <justus@klausecker.de> 2025-08-12 16:33:58+02:00
log277e4a8337b233a5d74f8f5b74d606210cf6fd97
treeea76b3852a13b15dd809157383d4a468730d6250
parent4ec421372f1d8dba8a2221d2ea9c774cdbefbe9d

fix: emit vector instead of scalar u1_zero in shl_with_overflow logic


2 files changed, 3 insertions(+), 4 deletions(-)

src/Sema.zig+1-2
......@@ -15620,7 +15620,6 @@ fn zirOverflowArithmetic(
1562015620 // If either of the arguments is undefined, IB is possible and we return an error.
1562115621 // If lhs is zero, the result is zero and no overflow occurred.
1562215622 // If rhs is zero, the result is lhs and no overflow occurred.
15623 // Oterhwise if either of the arguments is undefined, both results are undefined.
1562415623 const scalar_ty = lhs_ty.scalarType(zcu);
1562515624 if (maybe_rhs_val) |rhs_val| {
1562615625 if (maybe_lhs_val) |lhs_val| {
......@@ -15661,7 +15660,7 @@ fn zirOverflowArithmetic(
1566115660 .lt => return sema.failWithNegativeShiftAmount(block, rhs_src, rhs_elem, elem_idx),
1566215661 }
1566315662 }
15664 if (!any_positive) break :result .{ .overflow_bit = .zero_u1, .inst = lhs };
15663 if (!any_positive) break :result .{ .overflow_bit = try pt.aggregateSplatValue(overflow_ty, .zero_u1), .inst = lhs };
1566515664 },
1566615665 else => unreachable,
1566715666 }
src/Sema/arith.zig+2-2
......@@ -1895,10 +1895,10 @@ fn intShlWithOverflow(
18951895 const info = lhs_ty.intInfo(zcu);
18961896
18971897 var lhs_space: Value.BigIntSpace = undefined;
1898 const lhs_bigint = lhs.toBigInt(&lhs_space, zcu);
1898 const lhs_bigint = try lhs.toBigIntSema(&lhs_space, pt);
18991899
19001900 const shift_amt: usize = @intCast(try rhs.toUnsignedIntSema(pt));
1901 if (shift_amt >= lhs_ty.intInfo(zcu).bits) {
1901 if (shift_amt >= info.bits) {
19021902 return sema.failWithTooLargeShiftAmount(block, lhs_ty, rhs, rhs_src, vec_idx);
19031903 }
19041904 var result_bigint = try intShlInner(sema, lhs_bigint, shift_amt);