Skip to content

Commit f628523

Browse files
Hardcode84claude
andcommitted
Fix nested _Rational in Pow codegen for negative exponents
When Pow(X, -1) is codegen'd and X contains a division (producing a _Rational on the stack), the base must be resolved to an MLIR value before wrapping in a new _Rational. Otherwise a nested _Rational propagates to floor/floordiv_expr which expects flat numerator and denominator values. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Ivan Butygin <ivan.butygin@gmail.com>
1 parent 99fc439 commit f628523

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

wave_lang/kernel/compiler/wave_codegen/emitter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,7 @@ def _get_const(val):
10971097
operand = _get_ir_value(base)
10981098
base = arith_d.muli(operand, operand)
10991099
if power < 0:
1100+
base = _resolve_rational(base)
11001101
stack.append(_Rational(_get_const(1), base))
11011102
else:
11021103
stack.append(base)

0 commit comments

Comments
 (0)