bug: fuse_mul_addsub missing c - a*b FMA fusion pattern#82
Open
shauray8 wants to merge 1 commit intoNVIDIA:mainfrom
Open
bug: fuse_mul_addsub missing c - a*b FMA fusion pattern#82shauray8 wants to merge 1 commit intoNVIDIA:mainfrom
shauray8 wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
Signed-off-by: shauray8 <shauray9@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
fuse_mul_addsubin_passes/rewrite_patterns.pyfuses four of the five natural FMA patterns but missed the case where the mul is on the rhs of a subtraction (c - a*b). The guard on the rhs-mul branch:excluded sub, so c - a*b fell through to
NoMatchand stayed as RawBinaryArithmeticOperation(mul) + RawBinaryArithmeticOperation(sub) in the IR instead of a single FusedMulAddOperation.This PR drops the op.fn == "add" guard, track rhs_is_mul, and negate mul_op.lhs instead of acc for the sub case so c - a*b emits fma(-a, b, c).
Tileiras has its own FMA contraction pass so the final SASS is identical for single-use intermediates either way. The gap is at the CuTile IR level.
Reproducer
Checklist