Repository navigation
Fixes #734: Fix implicit widening of f32 and c64 in math intrinsics - #1317
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
…ross f32/f64/c64/c128 This commit ensures that single-precision and complex math functions correctly invoke their precision-accurate intrinsic equivalents (e.g., `sqrtf` and `cexpf`) rather than silently promoting arguments to double precision or double precision complex numbers in C output. - `cgen.flow`: Added checks inside `flowc_cgen_emit_expr_inner` for `f32` and `c64` types. Re-routes functions like `sqrt`, `sin`, `fabs`, and `cabs` to their `*f` counterparts. - `mlirgen.flow`: Handled the mappings in `mlg_libc_sig` to emit `MT_F32` and `MT_C64` results for these functions on specific inputs. - Verified test semantics with `NaN` and `Inf` using the new `test_f32_c64_math_semantics.flow` language tests. - Recreated generated `flowc_stage_a.c` to reach the fixed point and integrated performance microbenchmarks (`math_loop.flow`). Co-authored-by: godofecht <[email protected]>
bae8f21 to
3951432
Compare
Bring the branch onto 29f4d86 so self-host picks up the #1277 ffi package goldens and #1291 MLIR corpus digests already refreshed on main. Keep main's bootstrap C here; regenerate after the math-intrinsic source is settled. Co-authored-by: Abhishek Shivakumar <[email protected]>
Expression types only recover idents, so fabs(-x) and exp(0.1) never selected the single-precision libm names. stdlib math is declared f32, so read the callee parameter type as well. That is the self-host cgen golden failure on #1317. Co-authored-by: Abhishek Shivakumar <[email protected]>
Bundle emit keeps each module in its own arena, so fn_id never sees stdlib/math.flow. Read the cross-module sig table (float / c64) and walk unary minus on the first argument. That is what the #1317 cgen goldens actually compile. Co-authored-by: Abhishek Shivakumar <[email protected]>
Checked-in Stage-A C must match compiler/src. The previous #1317 bootstrap predates main at 29f4d86 and the imported-signature *f selection. Fixed point at gen2. Co-authored-by: Abhishek Shivakumar <[email protected]>
Bring the branch onto c9ee445 so #1278 codegen taxes and #1297 vgpu conformance land under the math-intrinsic *f selection. Keep main's bootstrap C here; regenerate after the merged compiler/src is settled. Co-authored-by: Abhishek Shivakumar <[email protected]>
Checked-in Stage-A C must match compiler/src. The previous #1317 bootstrap predates main at c9ee445 (#1278 codegen taxes, #1297 vgpu) and the imported-signature *f selection. Fixed point at gen2. Co-authored-by: Abhishek Shivakumar <[email protected]>
…cs-1768170846667842294 # Conflicts: # compiler/bootstrap/flowc_stage_a Co-authored-by: Abhishek Shivakumar <[email protected]>
Reach a fixed point after merging incremental AST caching (#1302) onto the f32/c64 math-intrinsic cgen changes. Co-authored-by: Abhishek Shivakumar <[email protected]>
Bring the branch onto 64db9fb so #1309 compiler performance remarks land under the math-intrinsic *f selection. cgen.flow auto-merged both sides. Keep main's bootstrap C here; regenerate after compiler/src is settled. Co-authored-by: Abhishek Shivakumar <[email protected]>
Reach a fixed point after merging compiler performance remarks (#1309) onto the f32/c64 math-intrinsic *f selection. Fixed point at gen2. Co-authored-by: Abhishek Shivakumar <[email protected]>
Fixes #734 by preventing
f32andc64values from implicitly widening tof64/c128during standard library math calls. Instead, the backend intercepts these typed instances and outputs the precise generic functions to the compiled C (sqrtf,cabsf,cosf).This includes changes in
cgen.flowto handle routing based on parameter typing and modifyingmlg_libc_siginmlirgen.flow. Verified against a comprehensive set of functions:sqrt,pow,abs,cos,atan2,csqrt,cexpetc. Included semantics tests and benchmark loops.PR created automatically by Jules for task 1768170846667842294 started by @godofecht