Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tweaks
  • Loading branch information
JukkaL committed Jan 15, 2026
commit eed643df90a648c8e9a2e1e763629b450de33cad
13 changes: 4 additions & 9 deletions mypyc/irbuild/ll_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,6 @@ def coerce_int_to_fixed_width(self, src: Value, target_type: RType, line: int) -
assert is_fixed_width_rtype(target_type), target_type
assert isinstance(target_type, RPrimitive), target_type

res = Register(target_type)

fast, slow, end = BasicBlock(), BasicBlock(), BasicBlock()

check = self.check_tagged_short_int(src, line)
Expand All @@ -482,6 +480,7 @@ def coerce_int_to_fixed_width(self, src: Value, target_type: RType, line: int) -
else:
tmp = src
tmp = self.int_op(target_type, tmp, Integer(1, target_type), IntOp.RIGHT_SHIFT, line)
res = Register(target_type)
self.add(Assign(res, tmp))
self.goto(end)

Expand Down Expand Up @@ -518,7 +517,7 @@ def coerce_tagged_to_fixed_width_with_range_check(
overflow_block: BasicBlock,
success_block: BasicBlock,
line: int,
) -> Value:
) -> Register:
"""Helper to convert a tagged value to a smaller fixed-width type with range checking.

This method generates IR for converting a tagged integer (like short_int or the fast
Expand Down Expand Up @@ -552,9 +551,7 @@ def coerce_tagged_to_fixed_width_with_range_check(
upper_bound *= 2

# Check if value < upper_bound
check_upper = self.add(
ComparisonOp(src, Integer(upper_bound, src.type), ComparisonOp.SLT)
)
check_upper = self.add(ComparisonOp(src, Integer(upper_bound, src.type), ComparisonOp.SLT))
self.add(Branch(check_upper, in_range, overflow_block, Branch.BOOL))

self.activate_block(in_range)
Expand All @@ -564,9 +561,7 @@ def coerce_tagged_to_fixed_width_with_range_check(
lower_bound = -upper_bound
else:
lower_bound = 0
check_lower = self.add(
ComparisonOp(src, Integer(lower_bound, src.type), ComparisonOp.SGE)
)
check_lower = self.add(ComparisonOp(src, Integer(lower_bound, src.type), ComparisonOp.SGE))
self.add(Branch(check_lower, in_range2, overflow_block, Branch.BOOL))

self.activate_block(in_range2)
Expand Down