| ... | @@ -10269,16 +10269,14 @@ fn zirShl( | ... | @@ -10269,16 +10269,14 @@ fn zirShl( |
| 10269 | | 10269 | |
| 10270 | const val = switch (air_tag) { | 10270 | const val = switch (air_tag) { |
| 10271 | .shl_exact => val: { | 10271 | .shl_exact => val: { |
| 10272 | const shifted = try lhs_val.shl(rhs_val, lhs_ty, sema.arena, target); | 10272 | const shifted = try lhs_val.shlWithOverflow(rhs_val, lhs_ty, sema.arena, target); |
| 10273 | if (scalar_ty.zigTypeTag() == .ComptimeInt) { | 10273 | if (scalar_ty.zigTypeTag() == .ComptimeInt) { |
| 10274 | break :val shifted; | 10274 | break :val shifted.wrapped_result; |
| 10275 | } | 10275 | } |
| 10276 | const int_info = scalar_ty.intInfo(target); | 10276 | if (shifted.overflowed.compareWithZero(.eq)) { |
| 10277 | const truncated = try shifted.intTrunc(lhs_ty, sema.arena, int_info.signedness, int_info.bits, target); | 10277 | break :val shifted.wrapped_result; |
| 10278 | if (try sema.compare(block, src, truncated, .eq, shifted, lhs_ty)) { | | |
| 10279 | break :val shifted; | | |
| 10280 | } | 10278 | } |
| 10281 | return sema.addConstUndef(lhs_ty); | 10279 | return sema.fail(block, src, "operation caused overflow", .{}); |
| 10282 | }, | 10280 | }, |
| 10283 | | 10281 | |
| 10284 | .shl_sat => if (scalar_ty.zigTypeTag() == .ComptimeInt) | 10282 | .shl_sat => if (scalar_ty.zigTypeTag() == .ComptimeInt) |