Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nothrow modeling of have_fma #43785

Merged
merged 1 commit into from
Jan 14, 2022
Merged

Fix nothrow modeling of have_fma #43785

merged 1 commit into from
Jan 14, 2022

Conversation

Keno
Copy link
Member

@Keno Keno commented Jan 12, 2022

Allows functions that make use of fma to be considered ConstAPI
(so long has both have_fma branches return the same constant).

cc @ianatol

Allows functions that make use of fma to be considered ConstAPI
(so long has both have_fma branches return the same constant).
@Keno Keno force-pushed the kf/have_fma_nothrow branch from 2036259 to 6c1eda3 Compare January 13, 2022 04:22
Comment on lines +631 to +632
intrinsic_effect_free_if_nothrow(f) = f === Intrinsics.pointerref ||
f === Intrinsics.have_fma || is_pure_intrinsic_infer(f)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
intrinsic_effect_free_if_nothrow(f) = f === Intrinsics.pointerref ||
f === Intrinsics.have_fma || is_pure_intrinsic_infer(f)
intrinsic_effect_free_if_nothrow(f) =
f === Intrinsics.pointerref ||
# in order to allow FMA multiversioning, we exclude `have_fma` from `is_pure_intrinsic_infer`
# because it shouldn't be constant folded at inference time, but we still mark it here
# so that we allow a call with `have_fma` to use the constant calling convention
# when both branches have the same constant value.
f === Intrinsics.have_fma ||
is_pure_intrinsic_infer(f)

Copy link
Member Author

Choose a reason for hiding this comment

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

Multiversioning is one of the issues, but it's not exclusive. Everything here that reads implicit runtime state needs to be excluded. If it is not guaranteed to always return bitwise egal output given bitwise egal input, it must be excluded from is_pure_intrinsic_infer. I'm working on a PR to make the effect free code a little more principled, so I'll fold the documentation comment in there.

@Keno Keno merged commit 294b0df into master Jan 14, 2022
@Keno Keno deleted the kf/have_fma_nothrow branch January 14, 2022 01:14
nickrobinson251 pushed a commit to nickrobinson251/julia that referenced this pull request Jan 14, 2022
Allows functions that make use of fma to be considered ConstAPI
(so long has both have_fma branches return the same constant).
nickrobinson251 pushed a commit to nickrobinson251/julia that referenced this pull request Jan 14, 2022
Allows functions that make use of fma to be considered ConstAPI
(so long has both have_fma branches return the same constant).
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
Allows functions that make use of fma to be considered ConstAPI
(so long has both have_fma branches return the same constant).
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
Allows functions that make use of fma to be considered ConstAPI
(so long has both have_fma branches return the same constant).
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.

4 participants