Skip to content

Commit db71832

Browse files
committed
fix: emit vector instead of scalar u1_zero in shl_with_overflow logic
1 parent 8edd930 commit db71832

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/Sema.zig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

0 commit comments

Comments
 (0)