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

(release 20.x non-upstream patch) [LV] Teach the vectorizer to cost and vectorize llvm.sincos intrinsics #84

Merged

Conversation

MacDue
Copy link
Contributor

@MacDue MacDue commented Feb 10, 2025

This teaches the loop vectorizer that llvm.sincos is trivially vectorizable. Additionally, this patch updates the cost model to cost intrinsics that return multiple values correctly. Previously, the cost model only thought intrinsics that return VectorType need scalarizing, which meant it cost intrinsics that return multiple vectors (that need scalarizing) way too cheap (giving it the cost of a single function call).

The llvm.sincos intrinsic also has a custom cost when a vector function library is available, as certain VFs can be expanded (later in code-gen) to a vector function, reducing the cost to a single call (+ the possible loads from the vector function returns values via output pointers).


Downstream issue: #87

@MacDue
Copy link
Contributor Author

MacDue commented Feb 10, 2025

Depends on #82. This PR is a copy of the LLVM PR llvm/llvm-project#123210, which was not possible to upstream for the release.

@david-arm
Copy link
Contributor

Does this need to be kept in-sync with the upstream version - llvm/llvm-project#123210?

@MacDue
Copy link
Contributor Author

MacDue commented Feb 20, 2025

Does this need to be kept in-sync with the upstream version - llvm/llvm-project#123210?

It's not hugely important to as all the changes to the upstream version have all been NFCs (so far), but I will update it anyway once #84 lands.

@MacDue MacDue force-pushed the release_20_sincos_vec branch from 78601b9 to ceec695 Compare February 27, 2025 10:25
This teaches the loop vectorizer that `llvm.sincos` is trivially
vectorizable. Additionally, this patch updates the cost model to cost
intrinsics that return multiple values correctly. Previously, the cost
model only thought intrinsics that return `VectorType` need scalarizing,
which meant it cost intrinsics that return multiple vectors (that need
scalarizing) way too cheap (giving it the cost of a single function
call).

The `llvm.sincos` intrinsic also has a custom cost when a vector
function library is available, as certain VFs can be expanded (later in
code-gen) to a vector function, reducing the cost to a single call (+
the possible loads from the vector function returns values via output
pointers).
@MacDue MacDue force-pushed the release_20_sincos_vec branch from ceec695 to 0763c9f Compare February 27, 2025 10:28
@MacDue MacDue marked this pull request as ready for review February 27, 2025 11:16
Copy link
Contributor

@kiranchandramohan kiranchandramohan left a comment

Choose a reason for hiding this comment

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

LGTM. Assuming this is a cherry-pick with all changes from upstream.

What about llvm/llvm-project#128035 and llvm/llvm-project#128885. Are they also required?

@MacDue
Copy link
Contributor Author

MacDue commented Feb 27, 2025

LGTM. Assuming this is a cherry-pick with all changes from upstream.

Yes, all of this is cherry-picked from patches that have landed in LLVM upstream.

What about llvm/llvm-project#128035 and llvm/llvm-project#128885. Are they also required?

llvm/llvm-project#128035 is part of this PR -- it was in the original upstream PR too, but split off for review purposes (but I don't think that's necessary here).

llvm/llvm-project#128885 is not required (it's just test changes).

@MacDue
Copy link
Contributor Author

MacDue commented Feb 27, 2025

I'd like to hold off landing this till tomorrow morning, just in case there's any reports upstream from the changes in llvm/llvm-project#128035, but otherwise this is ready to go.

@MacDue
Copy link
Contributor Author

MacDue commented Feb 28, 2025

@kiranchandramohan Can you merge this PR?

@kiranchandramohan kiranchandramohan merged commit 6b6acb9 into arm:release/arm-software/20.x Feb 28, 2025
@MacDue MacDue deleted the release_20_sincos_vec branch February 28, 2025 11:05
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