Skip to content

Commit e35d4c0

Browse files
r41k0uclaude
andcommitted
Core: Pass the result sign to the operator in augmented assignment
The binary-operation path chooses sdiv/udiv, srem/urem and ashr/lshr from the promoted type; the augmented-assignment path computed the same promoted type and then called apply_binop without it, so u32 >>= 4 was an ashr and u32 //= 3 an sdiv. Same call as the binop path now. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent 9cd8e10 commit e35d4c0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎pythonbpf/functions/functions_pass.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from pythonbpf.helper import (
77
HelperHandlerRegistry,
88
)
9-
from pythonbpf.type_deducer import ctypes_to_ir, is_ctypes
9+
from pythonbpf.type_deducer import ctypes_to_ir, is_ctypes, signedness
1010
from pythonbpf.expr import (
1111
eval_expr,
1212
handle_expr,
@@ -283,7 +283,9 @@ def handle_aug_assign(func, compilation_context, builder, stmt, local_sym_tab):
283283
current = to_promoted(builder, current, slot_type, result_ty)
284284
rhs = to_promoted(builder, rhs, rhs_ty, result_ty)
285285
result = canonicalise(
286-
builder, apply_binop(builder, stmt.op, current, rhs), result_ty
286+
builder,
287+
apply_binop(builder, stmt.op, current, rhs, signedness(result_ty)),
288+
result_ty,
287289
)
288290
builder.store(convert(builder, result, result_ty, slot_type), slot)
289291

0 commit comments

Comments
 (0)