Skip to content

Add select#15

Merged
ivogabe merged 15 commits intoivogabe:new-pipelinefrom
Doppie23:select
Mar 4, 2026
Merged

Add select#15
ivogabe merged 15 commits intoivogabe:new-pipelinefrom
Doppie23:select

Conversation

@Doppie23
Copy link

@Doppie23 Doppie23 commented Feb 19, 2026

Description

Introduces a select function that chooses a value based on a condition without branching.
select is similar to cond except it evaluates both branches and picks the result without branching.

cond will automatically be simplified to a select when both branches are considered cheap, based on a simple cost heuristic.

(&&) and (||) are defined using if-then-else to enable short-circuiting. Using this new logic these can now get converted to a select, which then will be turned into a logical and/or.

The accelerate-llvm part: ivogabe/accelerate-llvm#11

How has this been tested?
-

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@Doppie23 Doppie23 marked this pull request as ready for review March 2, 2026 19:53
@ivogabe ivogabe merged commit 8cd30e3 into ivogabe:new-pipeline Mar 4, 2026
3 of 39 checks passed
@ivogabe
Copy link
Owner

ivogabe commented Mar 4, 2026

Thanks! I tuned the cond-to-select transformation slightly in 97014c7, and added a transformation that converts a select of a pair to a pair of selects (to enable further optimizations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants