@@ -14029,8 +14029,8 @@ fn zirShl(
14029
14029
const maybe_rhs_val = try sema.resolveValueResolveLazy(rhs);
14030
14030
14031
14031
if (maybe_rhs_val) |rhs_val| {
14032
- if (rhs_val.isUndef (zcu)) {
14033
- return pt.undefRef(lhs_ty );
14032
+ if (rhs_val.anyScalarIsUndef (zcu)) {
14033
+ return sema.failWithUseOfUndef(block, rhs_src );
14034
14034
}
14035
14035
// If rhs is 0, return lhs without doing any calculations.
14036
14036
if (try rhs_val.compareAllWithZeroSema(.eq, pt)) {
@@ -14042,7 +14042,6 @@ fn zirShl(
14042
14042
var i: usize = 0;
14043
14043
while (i < rhs_ty.vectorLen(zcu)) : (i += 1) {
14044
14044
const rhs_elem = try rhs_val.elemValue(pt, i);
14045
- if (rhs_elem.isUndef(zcu)) continue;
14046
14045
if (rhs_elem.compareHetero(.gte, bit_value, zcu)) {
14047
14046
return sema.fail(block, rhs_src, "shift amount '{f}' at index '{d}' is too large for operand type '{f}'", .{
14048
14047
rhs_elem.fmtValueSema(pt, sema),
@@ -14060,23 +14059,15 @@ fn zirShl(
14060
14059
}
14061
14060
if (rhs_ty.zigTypeTag(zcu) == .vector) {
14062
14061
var i: usize = 0;
14063
- var undef_count: usize = 0;
14064
14062
while (i < rhs_ty.vectorLen(zcu)) : (i += 1) {
14065
14063
const rhs_elem = try rhs_val.elemValue(pt, i);
14066
- if (rhs_elem.isUndef(zcu)) {
14067
- undef_count += 1;
14068
- continue;
14069
- }
14070
14064
if (rhs_elem.compareHetero(.lt, try pt.intValue(scalar_rhs_ty, 0), zcu)) {
14071
14065
return sema.fail(block, rhs_src, "shift by negative amount '{f}' at index '{d}'", .{
14072
14066
rhs_elem.fmtValueSema(pt, sema),
14073
14067
i,
14074
14068
});
14075
14069
}
14076
14070
}
14077
- if (undef_count == rhs_ty.vectorLen(zcu)) {
14078
- return pt.undefRef(lhs_ty);
14079
- }
14080
14071
} else if (rhs_val.compareHetero(.lt, try pt.intValue(rhs_ty, 0), zcu)) {
14081
14072
return sema.fail(block, rhs_src, "shift by negative amount '{f}'", .{
14082
14073
rhs_val.fmtValueSema(pt, sema),
@@ -14087,7 +14078,9 @@ fn zirShl(
14087
14078
}
14088
14079
14089
14080
const runtime_src = if (maybe_lhs_val) |lhs_val| rs: {
14090
- if (lhs_val.isUndef(zcu)) return pt.undefRef(lhs_ty);
14081
+ if (lhs_val.anyScalarIsUndef(zcu)) {
14082
+ return sema.failWithUseOfUndef(block, lhs_src);
14083
+ }
14091
14084
const rhs_val = maybe_rhs_val orelse {
14092
14085
if (scalar_ty.zigTypeTag(zcu) == .comptime_int) {
14093
14086
return sema.fail(block, src, "LHS of shift must be a fixed-width integer type, or RHS must be comptime-known", .{});
@@ -14126,16 +14119,10 @@ fn zirShl(
14126
14119
)).toIntern();
14127
14120
const rhs_len = rhs_ty.vectorLen(zcu);
14128
14121
const rhs_elems = try sema.arena.alloc(InternPool.Index, rhs_len);
14129
- for (rhs_elems, 0..) |*rhs_elem, i| {
14130
- const elem_val = try rhs_val.elemValue(pt, i);
14131
- const min_val = if (elem_val.isUndef(zcu))
14132
- bit_count
14133
- else if (try elem_val.getUnsignedIntSema(pt)) |uint|
14134
- @min(uint, bit_count)
14135
- else
14136
- bit_count;
14137
- rhs_elem.* = (try pt.intValue(rt_rhs_scalar_ty, min_val)).toIntern();
14138
- }
14122
+ for (rhs_elems, 0..) |*rhs_elem, i| rhs_elem.* = (try pt.intValue(
14123
+ rt_rhs_scalar_ty,
14124
+ @min(try (try rhs_val.elemValue(pt, i)).getUnsignedIntSema(pt) orelse bit_count, bit_count),
14125
+ )).toIntern();
14139
14126
break :rt_rhs try pt.intern(.{ .aggregate = .{
14140
14127
.ty = (try pt.vectorType(.{
14141
14128
.len = rhs_len,
0 commit comments