| ... | ... | @@ -574,11 +574,13 @@ pub const Block = struct { |
| 574 | 574 | }); |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | | fn addCmpVector(block: *Block, lhs: Air.Inst.Ref, rhs: Air.Inst.Ref, cmp_op: std.math.CompareOperator, vector_ty: Air.Inst.Ref) !Air.Inst.Ref { |
| 577 | fn addCmpVector(block: *Block, lhs: Air.Inst.Ref, rhs: Air.Inst.Ref, cmp_op: std.math.CompareOperator) !Air.Inst.Ref { |
| 578 | 578 | return block.addInst(.{ |
| 579 | 579 | .tag = if (block.float_mode == .Optimized) .cmp_vector_optimized else .cmp_vector, |
| 580 | 580 | .data = .{ .ty_pl = .{ |
| 581 | | .ty = vector_ty, |
| 581 | .ty = try block.sema.addType( |
| 582 | try Type.vector(block.sema.arena, block.sema.typeOf(lhs).vectorLen(), Type.bool), |
| 583 | ), |
| 582 | 584 | .payload = try block.sema.addExtra(Air.VectorCmp{ |
| 583 | 585 | .lhs = lhs, |
| 584 | 586 | .rhs = rhs, |
| ... | ... | @@ -9412,7 +9414,7 @@ fn intCast( |
| 9412 | 9414 | const ok = if (is_vector) ok: { |
| 9413 | 9415 | const zeros = try Value.Tag.repeated.create(sema.arena, Value.zero); |
| 9414 | 9416 | const zero_inst = try sema.addConstant(sema.typeOf(operand), zeros); |
| 9415 | | const is_in_range = try block.addCmpVector(operand, zero_inst, .eq, try sema.addType(operand_ty)); |
| 9417 | const is_in_range = try block.addCmpVector(operand, zero_inst, .eq); |
| 9416 | 9418 | const all_in_range = try block.addInst(.{ |
| 9417 | 9419 | .tag = .reduce, |
| 9418 | 9420 | .data = .{ .reduce = .{ .operand = is_in_range, .operation = .And } }, |
| ... | ... | @@ -9466,7 +9468,7 @@ fn intCast( |
| 9466 | 9468 | const dest_range = try sema.addConstant(unsigned_operand_ty, dest_range_val); |
| 9467 | 9469 | |
| 9468 | 9470 | const ok = if (is_vector) ok: { |
| 9469 | | const is_in_range = try block.addCmpVector(diff_unsigned, dest_range, .lte, try sema.addType(operand_ty)); |
| 9471 | const is_in_range = try block.addCmpVector(diff_unsigned, dest_range, .lte); |
| 9470 | 9472 | const all_in_range = try block.addInst(.{ |
| 9471 | 9473 | .tag = if (block.float_mode == .Optimized) .reduce_optimized else .reduce, |
| 9472 | 9474 | .data = .{ .reduce = .{ |
| ... | ... | @@ -9483,7 +9485,7 @@ fn intCast( |
| 9483 | 9485 | try sema.addSafetyCheck(block, ok, .cast_truncated_data); |
| 9484 | 9486 | } else { |
| 9485 | 9487 | const ok = if (is_vector) ok: { |
| 9486 | | const is_in_range = try block.addCmpVector(diff, dest_max, .lte, try sema.addType(operand_ty)); |
| 9488 | const is_in_range = try block.addCmpVector(diff, dest_max, .lte); |
| 9487 | 9489 | const all_in_range = try block.addInst(.{ |
| 9488 | 9490 | .tag = if (block.float_mode == .Optimized) .reduce_optimized else .reduce, |
| 9489 | 9491 | .data = .{ .reduce = .{ |
| ... | ... | @@ -9504,7 +9506,7 @@ fn intCast( |
| 9504 | 9506 | const ok = if (is_vector) ok: { |
| 9505 | 9507 | const zero_val = try Value.Tag.repeated.create(sema.arena, Value.zero); |
| 9506 | 9508 | const zero_inst = try sema.addConstant(operand_ty, zero_val); |
| 9507 | | const is_in_range = try block.addCmpVector(operand, zero_inst, .gte, try sema.addType(operand_ty)); |
| 9509 | const is_in_range = try block.addCmpVector(operand, zero_inst, .gte); |
| 9508 | 9510 | const all_in_range = try block.addInst(.{ |
| 9509 | 9511 | .tag = if (block.float_mode == .Optimized) .reduce_optimized else .reduce, |
| 9510 | 9512 | .data = .{ .reduce = .{ |
| ... | ... | @@ -12016,7 +12018,7 @@ fn zirShl( |
| 12016 | 12018 | |
| 12017 | 12019 | const ok = if (rhs_ty.zigTypeTag() == .Vector) ok: { |
| 12018 | 12020 | const bit_count_inst = try sema.addConstant(rhs_ty, try Value.Tag.repeated.create(sema.arena, bit_count_val)); |
| 12019 | | const lt = try block.addCmpVector(rhs, bit_count_inst, .lt, try sema.addType(rhs_ty)); |
| 12021 | const lt = try block.addCmpVector(rhs, bit_count_inst, .lt); |
| 12020 | 12022 | break :ok try block.addInst(.{ |
| 12021 | 12023 | .tag = .reduce, |
| 12022 | 12024 | .data = .{ .reduce = .{ |
| ... | ... | @@ -12172,7 +12174,7 @@ fn zirShr( |
| 12172 | 12174 | |
| 12173 | 12175 | const ok = if (rhs_ty.zigTypeTag() == .Vector) ok: { |
| 12174 | 12176 | const bit_count_inst = try sema.addConstant(rhs_ty, try Value.Tag.repeated.create(sema.arena, bit_count_val)); |
| 12175 | | const lt = try block.addCmpVector(rhs, bit_count_inst, .lt, try sema.addType(rhs_ty)); |
| 12177 | const lt = try block.addCmpVector(rhs, bit_count_inst, .lt); |
| 12176 | 12178 | break :ok try block.addInst(.{ |
| 12177 | 12179 | .tag = .reduce, |
| 12178 | 12180 | .data = .{ .reduce = .{ |
| ... | ... | @@ -12191,7 +12193,7 @@ fn zirShr( |
| 12191 | 12193 | const back = try block.addBinOp(.shl, result, rhs); |
| 12192 | 12194 | |
| 12193 | 12195 | const ok = if (rhs_ty.zigTypeTag() == .Vector) ok: { |
| 12194 | | const eql = try block.addCmpVector(lhs, back, .eq, try sema.addType(rhs_ty)); |
| 12196 | const eql = try block.addCmpVector(lhs, back, .eq); |
| 12195 | 12197 | break :ok try block.addInst(.{ |
| 12196 | 12198 | .tag = if (block.float_mode == .Optimized) .reduce_optimized else .reduce, |
| 12197 | 12199 | .data = .{ .reduce = .{ |
| ... | ... | @@ -13192,7 +13194,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13192 | 13194 | const floored = try block.addUnOp(.floor, result); |
| 13193 | 13195 | |
| 13194 | 13196 | if (resolved_type.zigTypeTag() == .Vector) { |
| 13195 | | const eql = try block.addCmpVector(result, floored, .eq, try sema.addType(resolved_type)); |
| 13197 | const eql = try block.addCmpVector(result, floored, .eq); |
| 13196 | 13198 | break :ok try block.addInst(.{ |
| 13197 | 13199 | .tag = switch (block.float_mode) { |
| 13198 | 13200 | .Strict => .reduce, |
| ... | ... | @@ -13216,7 +13218,7 @@ fn zirDivExact(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13216 | 13218 | if (resolved_type.zigTypeTag() == .Vector) { |
| 13217 | 13219 | const zero_val = try Value.Tag.repeated.create(sema.arena, Value.zero); |
| 13218 | 13220 | const zero = try sema.addConstant(resolved_type, zero_val); |
| 13219 | | const eql = try block.addCmpVector(remainder, zero, .eq, try sema.addType(resolved_type)); |
| 13221 | const eql = try block.addCmpVector(remainder, zero, .eq); |
| 13220 | 13222 | break :ok try block.addInst(.{ |
| 13221 | 13223 | .tag = .reduce, |
| 13222 | 13224 | .data = .{ .reduce = .{ |
| ... | ... | @@ -13514,14 +13516,13 @@ fn addDivIntOverflowSafety( |
| 13514 | 13516 | |
| 13515 | 13517 | var ok: Air.Inst.Ref = .none; |
| 13516 | 13518 | if (resolved_type.zigTypeTag() == .Vector) { |
| 13517 | | const vector_ty_ref = try sema.addType(resolved_type); |
| 13518 | 13519 | if (maybe_lhs_val == null) { |
| 13519 | 13520 | const min_int_ref = try sema.addConstant(resolved_type, min_int); |
| 13520 | | ok = try block.addCmpVector(casted_lhs, min_int_ref, .neq, vector_ty_ref); |
| 13521 | ok = try block.addCmpVector(casted_lhs, min_int_ref, .neq); |
| 13521 | 13522 | } |
| 13522 | 13523 | if (maybe_rhs_val == null) { |
| 13523 | 13524 | const neg_one_ref = try sema.addConstant(resolved_type, neg_one); |
| 13524 | | const rhs_ok = try block.addCmpVector(casted_rhs, neg_one_ref, .neq, vector_ty_ref); |
| 13525 | const rhs_ok = try block.addCmpVector(casted_rhs, neg_one_ref, .neq); |
| 13525 | 13526 | if (ok == .none) { |
| 13526 | 13527 | ok = rhs_ok; |
| 13527 | 13528 | } else { |
| ... | ... | @@ -13573,7 +13574,7 @@ fn addDivByZeroSafety( |
| 13573 | 13574 | const ok = if (resolved_type.zigTypeTag() == .Vector) ok: { |
| 13574 | 13575 | const zero_val = try Value.Tag.repeated.create(sema.arena, Value.zero); |
| 13575 | 13576 | const zero = try sema.addConstant(resolved_type, zero_val); |
| 13576 | | const ok = try block.addCmpVector(casted_rhs, zero, .neq, try sema.addType(resolved_type)); |
| 13577 | const ok = try block.addCmpVector(casted_rhs, zero, .neq); |
| 13577 | 13578 | break :ok try block.addInst(.{ |
| 13578 | 13579 | .tag = if (is_int) .reduce else .reduce_optimized, |
| 13579 | 13580 | .data = .{ .reduce = .{ |
| ... | ... | @@ -15202,9 +15203,7 @@ fn cmpSelf( |
| 15202 | 15203 | }; |
| 15203 | 15204 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 15204 | 15205 | if (resolved_type.zigTypeTag() == .Vector) { |
| 15205 | | const result_ty = try Type.vector(sema.arena, resolved_type.vectorLen(), Type.bool); |
| 15206 | | const result_ty_ref = try sema.addType(result_ty); |
| 15207 | | return block.addCmpVector(casted_lhs, casted_rhs, op, result_ty_ref); |
| 15206 | return block.addCmpVector(casted_lhs, casted_rhs, op); |
| 15208 | 15207 | } |
| 15209 | 15208 | const tag = Air.Inst.Tag.fromCmpOp(op, block.float_mode == .Optimized); |
| 15210 | 15209 | return block.addBinOp(tag, casted_lhs, casted_rhs); |
| ... | ... | @@ -23035,7 +23034,7 @@ fn panicSentinelMismatch( |
| 23035 | 23034 | |
| 23036 | 23035 | const ok = if (sentinel_ty.zigTypeTag() == .Vector) ok: { |
| 23037 | 23036 | const eql = |
| 23038 | | try parent_block.addCmpVector(expected_sentinel, actual_sentinel, .eq, try sema.addType(sentinel_ty)); |
| 23037 | try parent_block.addCmpVector(expected_sentinel, actual_sentinel, .eq); |
| 23039 | 23038 | break :ok try parent_block.addInst(.{ |
| 23040 | 23039 | .tag = .reduce, |
| 23041 | 23040 | .data = .{ .reduce = .{ |
| ... | ... | @@ -29368,8 +29367,7 @@ fn cmpVector( |
| 29368 | 29367 | }; |
| 29369 | 29368 | |
| 29370 | 29369 | try sema.requireRuntimeBlock(block, src, runtime_src); |
| 29371 | | const result_ty_inst = try sema.addType(result_ty); |
| 29372 | | return block.addCmpVector(lhs, rhs, op, result_ty_inst); |
| 29370 | return block.addCmpVector(lhs, rhs, op); |
| 29373 | 29371 | } |
| 29374 | 29372 | |
| 29375 | 29373 | fn wrapOptional( |