Repository navigation
Conversation
When converting 'if' blocks to C ternary selects, evaluating the array index unconditionally could result in array out of bounds exceptions or segfaults (as in test_hybrid_events and test_stdlib_regex). This safely restricts the ternary select optimization so it does not evaluate unless 'else' is provided, matching exactly the behavior needed to solve the failures. Also updates the relevant tests/cli/goldens. Co-authored-by: godofecht <[email protected]>
|
👋 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. |
|
Duplicate of #1363, which is kept as the canonical #739 PR. This branch squashes #1363 with one fix, and on current main it also deletes .github/workflows/attribution-guard.yml. The fix is listed in the merge queue to fold into #1363: in compiler/src/cgen.flow, |
Understood. Acknowledging that this work is now obsolete and stopping work on this task. |
…739) Folded into the rebased feature commit while resolving it against #1417: - Span copies use memcpy through .data only when flowc_region_disjoint proves the regions disjoint; otherwise the ordered loop stays. The branch's memmove path would snapshot a shifted view (dst = src + 1) that the scalar loop treats as a recurrence. - The scale, axpy and add vector_size kernels run only when every read base is the destination itself or proven disjoint from it, the scalar factor reads no memory and calls nothing (it is hoisted), all bases share the element type, and FLOWC_CHECKS is off (the kernels move whole lanes past the per-index bounds tests). - Salvaged from closed #1396 (commit 2eedcac): flowc_cgen_if_is_select returns flowc_cgen_select_exprs_ok, and an if without else is never a select, so `if c { a[i] = v }` no longer reads a[i] when c is the bounds guard (test_hybrid_events, test_stdlib_regex). Tests: for_simd_kernel_overlap (runtime recurrence on shifted views; the branch's original compiler exits 1), for_simd_kernel_disjoint, for_simd_kernel_checked, for_simd_select_noelse, and for_simd_span_copy (parameters keep the loop, disjoint locals memcpy). All of them fail on the branch's original compiler.
Counted whiles rotate to a C for with the clang hint and GCC ivdep. Unit-stride span copies use one memcpy through .data when region inference proves the regions disjoint, otherwise the ordered loop stays (#1417). Clip/min-max if/else stores to one index become a ternary select; an if without else keeps the branch (folded from closed #1396). f32/f64 fill/scale/axpy/add/sum/dot use vector_size(16) kernels behind FLOWC_HAS_V128 only when every read base is the destination or proven disjoint, the scalar factor is pure, and FLOWC_CHECKS is off. Goldens: for_simd_kernel_overlap, for_simd_kernel_disjoint, for_simd_kernel_checked, for_simd_select_noelse, for_simd_span_copy, for_simd_while, for_simd_clip. Part of #739.
This addresses follow-up work for #739, specifically fixing regressions introduced by the ternary select SIMD optimization in
#739.The compilation of
if cond { array[index] = val }intoarray[index] = cond ? val : array[index]was erroneously evaluatingarray[index]unconditionally whenelsewas absent (els == AST_NONE), leading to out of bounds exceptions in the runtime tests liketest_hybrid_eventsand a segmentation fault intest_stdlib_regex(due to dereferencingNULL). This optimization is now only applied if it is safe to do so. The PR includes updated goldens forcompile_hello,compile_isolated_root, andpython_source.PR created automatically by Jules for task 16390168949541202528 started by @godofecht