-
Notifications
You must be signed in to change notification settings - Fork 15.6k
[LoopVectorize] Support vectorization of frexp intrinsic #172957
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
base: main
Are you sure you want to change the base?
Conversation
|
@llvm/pr-subscribers-vectorizers @llvm/pr-subscribers-llvm-analysis Author: 陈子昂 (Michael-Chen-NJU) ChangesThis patch enables the vectorization of the llvm.frexp intrinsic. Following the suggestion in #112408, frexp is moved from isTriviallyScalarizable to isTriviallyVectorizable. Fixes #112408 Full diff: https://github.com/llvm/llvm-project/pull/172957.diff 1 Files Affected:
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index a3e9b039f9225..2fb502bb26f40 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -81,6 +81,7 @@ bool llvm::isTriviallyVectorizable(Intrinsic::ID ID) {
case Intrinsic::exp:
case Intrinsic::exp10:
case Intrinsic::exp2:
+ case Intrinsic::frexp:
case Intrinsic::ldexp:
case Intrinsic::log:
case Intrinsic::log10:
@@ -129,10 +130,7 @@ bool llvm::isTriviallyScalarizable(Intrinsic::ID ID,
if (TTI && Intrinsic::isTargetIntrinsic(ID))
return TTI->isTargetIntrinsicTriviallyScalarizable(ID);
- // TODO: Move frexp to isTriviallyVectorizable.
- // https://github.com/llvm/llvm-project/issues/112408
switch (ID) {
- case Intrinsic::frexp:
case Intrinsic::uadd_with_overflow:
case Intrinsic::sadd_with_overflow:
case Intrinsic::ssub_with_overflow:
|
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
MacDue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding a basic test to llvm/test/Transforms/LoopVectorize/multiple-result-intrinsics.ll
|
@MacDue I have added the test cases, but the LoopVectorize pass currently fails to vectorize them, providing the remark: |
|
I think that restriction could be relaxed in this case. When I added support for struct-returns the intrinsics I cared about all returned structs of the same type, but I don't think there's any reason we could not support mixed types. It may be worth investigating, it might be as simple as updating the check. |
|
@MacDue,I've updated the patch to support widening intrinsics with mixed-type struct returns (like llvm.frexp). Initially, lifting the legality restriction caused a crash because |
MacDue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits fixed 👍
This patch enables the vectorization of the llvm.frexp intrinsic. Following the suggestion in #112408, frexp is moved from isTriviallyScalarizable to isTriviallyVectorizable.
Fixes #112408