| ... | @@ -13341,28 +13341,14 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13341,28 +13341,14 @@ fn zirTruncate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13341 | const target = sema.mod.getTarget(); | 13341 | const target = sema.mod.getTarget(); |
| 13342 | const dest_info = dest_scalar_ty.intInfo(target); | 13342 | const dest_info = dest_scalar_ty.intInfo(target); |
| 13343 | | 13343 | |
| 13344 | if (dest_info.bits == 0) { | 13344 | if (try sema.typeHasOnePossibleValue(block, dest_ty_src, dest_ty)) |val| { |
| 13345 | if (is_vector) { | 13345 | return sema.addConstant(dest_ty, val); |
| 13346 | return sema.addConstant( | | |
| 13347 | dest_ty, | | |
| 13348 | try Value.Tag.repeated.create(sema.arena, Value.zero), | | |
| 13349 | ); | | |
| 13350 | } else { | | |
| 13351 | return sema.addConstant(dest_ty, Value.zero); | | |
| 13352 | } | | |
| 13353 | } | 13346 | } |
| 13354 | | 13347 | |
| 13355 | if (operand_scalar_ty.zigTypeTag() != .ComptimeInt) { | 13348 | if (operand_scalar_ty.zigTypeTag() != .ComptimeInt) { |
| 13356 | const operand_info = operand_ty.intInfo(target); | 13349 | const operand_info = operand_ty.intInfo(target); |
| 13357 | if (operand_info.bits == 0) { | 13350 | if (try sema.typeHasOnePossibleValue(block, operand_src, operand_ty)) |val| { |
| 13358 | if (is_vector) { | 13351 | return sema.addConstant(operand_ty, val); |
| 13359 | return sema.addConstant( | | |
| 13360 | dest_ty, | | |
| 13361 | try Value.Tag.repeated.create(sema.arena, Value.zero), | | |
| 13362 | ); | | |
| 13363 | } else { | | |
| 13364 | return sema.addConstant(dest_ty, Value.zero); | | |
| 13365 | } | | |
| 13366 | } | 13352 | } |
| 13367 | | 13353 | |
| 13368 | if (operand_info.signedness != dest_info.signedness) { | 13354 | if (operand_info.signedness != dest_info.signedness) { |
| ... | @@ -13461,15 +13447,9 @@ fn zirBitCount( | ... | @@ -13461,15 +13447,9 @@ fn zirBitCount( |
| 13461 | _ = try checkIntOrVector(sema, block, operand, operand_src); | 13447 | _ = try checkIntOrVector(sema, block, operand, operand_src); |
| 13462 | const target = sema.mod.getTarget(); | 13448 | const target = sema.mod.getTarget(); |
| 13463 | const bits = operand_ty.intInfo(target).bits; | 13449 | const bits = operand_ty.intInfo(target).bits; |
| 13464 | if (bits == 0) { | 13450 | |
| 13465 | switch (operand_ty.zigTypeTag()) { | 13451 | if (try sema.typeHasOnePossibleValue(block, operand_src, operand_ty)) |val| { |
| 13466 | .Vector => return sema.addConstant( | 13452 | return sema.addConstant(operand_ty, val); |
| 13467 | try Type.vector(sema.arena, operand_ty.vectorLen(), Type.comptime_int), | | |
| 13468 | try Value.Tag.repeated.create(sema.arena, Value.zero), | | |
| 13469 | ), | | |
| 13470 | .Int => return Air.Inst.Ref.zero, | | |
| 13471 | else => unreachable, | | |
| 13472 | } | | |
| 13473 | } | 13453 | } |
| 13474 | | 13454 | |
| 13475 | const result_scalar_ty = try Type.smallestUnsignedInt(sema.arena, bits); | 13455 | const result_scalar_ty = try Type.smallestUnsignedInt(sema.arena, bits); |
| ... | @@ -13528,10 +13508,12 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13528,10 +13508,12 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13528 | ); | 13508 | ); |
| 13529 | } | 13509 | } |
| 13530 | | 13510 | |
| | 13511 | if (try sema.typeHasOnePossibleValue(block, operand_src, operand_ty)) |val| { |
| | 13512 | return sema.addConstant(operand_ty, val); |
| | 13513 | } |
| | 13514 | |
| 13531 | switch (operand_ty.zigTypeTag()) { | 13515 | switch (operand_ty.zigTypeTag()) { |
| 13532 | .Int, .ComptimeInt => { | 13516 | .Int, .ComptimeInt => { |
| 13533 | if (bits == 0) return Air.Inst.Ref.zero; | | |
| 13534 | | | |
| 13535 | const runtime_src = if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { | 13517 | const runtime_src = if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { |
| 13536 | if (val.isUndef()) return sema.addConstUndef(operand_ty); | 13518 | if (val.isUndef()) return sema.addConstUndef(operand_ty); |
| 13537 | const result_val = try val.byteSwap(operand_ty, target, sema.arena); | 13519 | const result_val = try val.byteSwap(operand_ty, target, sema.arena); |
| ... | @@ -13542,13 +13524,6 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -13542,13 +13524,6 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 13542 | return block.addTyOp(.byte_swap, operand_ty, operand); | 13524 | return block.addTyOp(.byte_swap, operand_ty, operand); |
| 13543 | }, | 13525 | }, |
| 13544 | .Vector => { | 13526 | .Vector => { |
| 13545 | if (bits == 0) { | | |
| 13546 | return sema.addConstant( | | |
| 13547 | operand_ty, | | |
| 13548 | try Value.Tag.repeated.create(sema.arena, Value.zero), | | |
| 13549 | ); | | |
| 13550 | } | | |
| 13551 | | | |
| 13552 | const runtime_src = if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { | 13527 | const runtime_src = if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { |
| 13553 | if (val.isUndef()) | 13528 | if (val.isUndef()) |
| 13554 | return sema.addConstUndef(operand_ty); | 13529 | return sema.addConstUndef(operand_ty); |
| ... | @@ -13578,21 +13553,13 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! | ... | @@ -13578,21 +13553,13 @@ fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 13578 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; | 13553 | const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; |
| 13579 | const operand = sema.resolveInst(inst_data.operand); | 13554 | const operand = sema.resolveInst(inst_data.operand); |
| 13580 | const operand_ty = sema.typeOf(operand); | 13555 | const operand_ty = sema.typeOf(operand); |
| 13581 | const scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand, operand_src); | 13556 | _ = try sema.checkIntOrVectorAllowComptime(block, operand, operand_src); |
| 13582 | | 13557 | |
| 13583 | const target = sema.mod.getTarget(); | 13558 | if (try sema.typeHasOnePossibleValue(block, operand_src, operand_ty)) |val| { |
| 13584 | const bits = scalar_ty.intInfo(target).bits; | 13559 | return sema.addConstant(operand_ty, val); |
| 13585 | if (bits == 0) { | | |
| 13586 | switch (operand_ty.zigTypeTag()) { | | |
| 13587 | .Vector => return sema.addConstant( | | |
| 13588 | operand_ty, | | |
| 13589 | try Value.Tag.repeated.create(sema.arena, Value.zero), | | |
| 13590 | ), | | |
| 13591 | .Int => return Air.Inst.Ref.zero, | | |
| 13592 | else => unreachable, | | |
| 13593 | } | | |
| 13594 | } | 13560 | } |
| 13595 | | 13561 | |
| | 13562 | const target = sema.mod.getTarget(); |
| 13596 | switch (operand_ty.zigTypeTag()) { | 13563 | switch (operand_ty.zigTypeTag()) { |
| 13597 | .Int, .ComptimeInt => { | 13564 | .Int, .ComptimeInt => { |
| 13598 | const runtime_src = if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { | 13565 | const runtime_src = if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { |