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(...@@ -15620,7 +15620,6 @@ fn zirOverflowArithmetic(
15620 // If either of the arguments is undefined, IB is possible and we return an error.15620 // If either of the arguments is undefined, IB is possible and we return an error.
15621 // If lhs is zero, the result is zero and no overflow occurred.15621 // If lhs is zero, the result is zero and no overflow occurred.
15622 // If rhs is zero, the result is lhs and no overflow occurred.15622 // 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.
15624 const scalar_ty = lhs_ty.scalarType(zcu);15623 const scalar_ty = lhs_ty.scalarType(zcu);
15625 if (maybe_rhs_val) |rhs_val| {15624 if (maybe_rhs_val) |rhs_val| {
15626 if (maybe_lhs_val) |lhs_val| {15625 if (maybe_lhs_val) |lhs_val| {
...@@ -15661,7 +15660,7 @@ fn zirOverflowArithmetic(...@@ -15661,7 +15660,7 @@ fn zirOverflowArithmetic(
15661 .lt => return sema.failWithNegativeShiftAmount(block, rhs_src, rhs_elem, elem_idx),15660 .lt => return sema.failWithNegativeShiftAmount(block, rhs_src, rhs_elem, elem_idx),
15662 }15661 }
15663 }15662 }
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 };
15665 },15664 },
15666 else => unreachable,15665 else => unreachable,
15667 }15666 }
src/Sema/arith.zig+2-2
...@@ -1895,10 +1895,10 @@ fn intShlWithOverflow(...@@ -1895,10 +1895,10 @@ fn intShlWithOverflow(
1895 const info = lhs_ty.intInfo(zcu);1895 const info = lhs_ty.intInfo(zcu);
18961896
1897 var lhs_space: Value.BigIntSpace = undefined;1897 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
1900 const shift_amt: usize = @intCast(try rhs.toUnsignedIntSema(pt));1900 const shift_amt: usize = @intCast(try rhs.toUnsignedIntSema(pt));
1901 if (shift_amt >= lhs_ty.intInfo(zcu).bits) {1901 if (shift_amt >= info.bits) {
1902 return sema.failWithTooLargeShiftAmount(block, lhs_ty, rhs, rhs_src, vec_idx);1902 return sema.failWithTooLargeShiftAmount(block, lhs_ty, rhs, rhs_src, vec_idx);
1903 }1903 }
1904 var result_bigint = try intShlInner(sema, lhs_bigint, shift_amt);1904 var result_bigint = try intShlInner(sema, lhs_bigint, shift_amt);