Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Comments

fix: Add missing set_fast_math method#149

Closed
iihimanshuu wants to merge 1 commit intoarxlang:mainfrom
iihimanshuu:fix-fast-math
Closed

fix: Add missing set_fast_math method#149
iihimanshuu wants to merge 1 commit intoarxlang:mainfrom
iihimanshuu:fix-fast-math

Conversation

@iihimanshuu
Copy link
Contributor

Description:

Problem:
llvmliteir.py calls self.set_fast_math() at lines 603, 608, 612, and 660, but the method doesn't exist, causing AttributeError at runtime for vector operations with fast math.

Solution:
Added set_fast_math(enable: bool) method that enables/disables fast math flags on the LLVM IR builder using llvmlite's set_fastmath_flags(["fast"]) and clear_fastmath_flags() methods.

Closes #148

Reviewer's checklist

Copy and paste this template for your review's note:

## Reviewer's Checklist

- [ ] I managed to reproduce the problem locally from the `main` branch
- [ ] I managed to test the new changes locally
- [ ] I confirm that the issues mentioned were fixed/resolved .

@github-actions
Copy link

OSL ChatGPT Reviewer

NOTE: This is generated by an AI program, so some comments may not make sense.

src/irx/builders/llvmliteir.py

  • (L.426) Correctness: Typo in API call. llvmlite IRBuilder uses set_fast_math_flags, not set_fastmath_flags. The current code will raise AttributeError.
    Suggested change:
    def set_fast_math(self, enable: bool) -> None:
    """Enable or disable fast math flags on the IR builder."""
    if enable:
    self._llvm.ir_builder.set_fast_math_flags(["fast"])
    else:
    self._llvm.ir_builder.clear_fast_math_flags()

  • Behavioral risk: This unconditionally clobbers any existing fast-math configuration and then clears everything on disable, which can silently change semantics (NNAN/NINF/REASSOC, etc.). Consider preserving/restoring previous flags or offering a scoped/context-managed enable to avoid leaking state across codegen phases.

  • Compatibility: Verify the llvmlite version’s expected type for flags. Some versions prefer a FastMathFlags object over a list[str]. Consider accepting a Sequence[str] or FastMathFlags to avoid future breakage.


@iihimanshuu
Copy link
Contributor Author

@yuvimittal please review!

@iihimanshuu
Copy link
Contributor Author

@yuvimittal & @xmnlab please review the pr!

@yuvimittal
Copy link
Member

@iihimanshuu , i dont understand in which file does we call self.set_fast_math() where it doesn't exist!?
Also we should add tests as well for the method, and can you push and empty commit!? i am not able re-run the jobs, as github disables re-running old workflow runs!

@iihimanshuu
Copy link
Contributor Author

Thanks for looking at this. I opened this PR because set_fast_math() was being called but wasn’t defined at the time (Dec 15). I see you’ve since implemented a proper solution with tests on main, so my change is now redundant. I’ll close this PR—appreciate the quick fix!

@iihimanshuu , i dont understand in which file does we call self.set_fast_math() where it doesn't exist!? Also we should add tests as well for the method, and can you push and empty commit!? i am not able re-run the jobs, as github disables re-running old workflow runs!

@iihimanshuu iihimanshuu deleted the fix-fast-math branch January 19, 2026 14:36
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.

fix: add set_fast_math Method

2 participants