Commit dd4e25cf44
Changed files (1)
src
codegen
src/codegen/llvm.zig
@@ -9234,8 +9234,7 @@ pub const FuncGen = struct {
const dest_is_enum = dest_ty.zigTypeTag(zcu) == .@"enum";
- safety: {
- if (!safety) break :safety;
+ bounds_check: {
const dest_scalar = dest_ty.scalarType(zcu);
const operand_scalar = operand_ty.scalarType(zcu);
@@ -9254,7 +9253,7 @@ pub const FuncGen = struct {
};
};
- if (!have_min_check and !have_max_check) break :safety;
+ if (!have_min_check and !have_max_check) break :bounds_check;
const operand_llvm_ty = try o.lowerType(pt, operand_ty);
const operand_scalar_llvm_ty = try o.lowerType(pt, operand_scalar);
@@ -9272,12 +9271,16 @@ pub const FuncGen = struct {
const vec_ty = ok_maybe_vec.typeOfWip(&fg.wip);
break :ok try fg.wip.callIntrinsic(.normal, .none, .@"vector.reduce.and", &.{vec_ty}, &.{ok_maybe_vec}, "");
} else ok_maybe_vec;
- const fail_block = try fg.wip.block(1, "IntMinFail");
- const ok_block = try fg.wip.block(1, "IntMinOk");
- _ = try fg.wip.brCond(ok, ok_block, fail_block, .none);
- fg.wip.cursor = .{ .block = fail_block };
- try fg.buildSimplePanic(panic_id);
- fg.wip.cursor = .{ .block = ok_block };
+ if (safety) {
+ const fail_block = try fg.wip.block(1, "IntMinFail");
+ const ok_block = try fg.wip.block(1, "IntMinOk");
+ _ = try fg.wip.brCond(ok, ok_block, fail_block, .none);
+ fg.wip.cursor = .{ .block = fail_block };
+ try fg.buildSimplePanic(panic_id);
+ fg.wip.cursor = .{ .block = ok_block };
+ } else {
+ _ = try fg.wip.callIntrinsic(.normal, .none, .assume, &.{}, &.{ok}, "");
+ }
}
if (have_max_check) {
@@ -9288,12 +9291,16 @@ pub const FuncGen = struct {
const vec_ty = ok_maybe_vec.typeOfWip(&fg.wip);
break :ok try fg.wip.callIntrinsic(.normal, .none, .@"vector.reduce.and", &.{vec_ty}, &.{ok_maybe_vec}, "");
} else ok_maybe_vec;
- const fail_block = try fg.wip.block(1, "IntMaxFail");
- const ok_block = try fg.wip.block(1, "IntMaxOk");
- _ = try fg.wip.brCond(ok, ok_block, fail_block, .none);
- fg.wip.cursor = .{ .block = fail_block };
- try fg.buildSimplePanic(panic_id);
- fg.wip.cursor = .{ .block = ok_block };
+ if (safety) {
+ const fail_block = try fg.wip.block(1, "IntMaxFail");
+ const ok_block = try fg.wip.block(1, "IntMaxOk");
+ _ = try fg.wip.brCond(ok, ok_block, fail_block, .none);
+ fg.wip.cursor = .{ .block = fail_block };
+ try fg.buildSimplePanic(panic_id);
+ fg.wip.cursor = .{ .block = ok_block };
+ } else {
+ _ = try fg.wip.callIntrinsic(.normal, .none, .assume, &.{}, &.{ok}, "");
+ }
}
}