Skip to content

[Enh] Support chained comparison#799

Merged
coderfeli merged 1 commit into
mainfrom
pr/chained-comparison
Jul 5, 2026
Merged

[Enh] Support chained comparison#799
coderfeli merged 1 commit into
mainfrom
pr/chained-comparison

Conversation

@sjfeng1999

Copy link
Copy Markdown
Collaborator

Motivation

Technical Details

Test Plan

Test Result

Submission Checklist

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds frontend support for Python chained comparisons (e.g. a < b < c) by lowering them into boolean operations that FlyDSL can already rewrite/lower, and adds unit coverage for both dynamic IR tracing and constexpr evaluation.

Changes:

  • Add RewriteBoolOps.visit_Compare lowering of chained ast.Compare into BoolOp(And) to reuse existing and lowering.
  • Rename boolean hook dunders from __fly_*__ to __dsl_*__ in both the AST rewriter and Numeric.
  • Add unit tests covering dynamic chained-compare lowering and constexpr chained-compare acceptance.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/unit/test_if_dispatch_paths.py Adds a dynamic chained-compare test that verifies IR contains multiple cmpi and an andi.
tests/unit/test_constexpr.py Adds a constexpr chained-compare JIT test.
python/flydsl/expr/numeric.py Renames boolean hook dunders to __dsl_*__.
python/flydsl/compiler/ast_rewriter.py Adds chained-compare rewrite and updates bool-op hook dispatch to __dsl_*__.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python/flydsl/expr/numeric.py
Comment thread python/flydsl/compiler/ast_rewriter.py
Comment thread python/flydsl/compiler/ast_rewriter.py
@coderfeli coderfeli merged commit cc5bf8f into main Jul 5, 2026
13 checks passed
@coderfeli coderfeli deleted the pr/chained-comparison branch July 5, 2026 13:07
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.

3 participants