-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[X86] Combine uitofp <v x i32> to <v x half>
#121809
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
Conversation
@llvm/pr-subscribers-llvm-selectiondag @llvm/pr-subscribers-backend-x86 Author: None (abhishek-kaushik22) ChangesCloses #121793 Full diff: https://github.com/llvm/llvm-project/pull/121809.diff 1 Files Affected:
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 68bdeb1cebeb9c..156ad47efcbf4f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -56098,8 +56098,19 @@ static SDValue combineUIntToFP(SDNode *N, SelectionDAG &DAG,
if (InVT.isVector() && VT.getVectorElementType() == MVT::f16) {
unsigned ScalarSize = InVT.getScalarSizeInBits();
if ((ScalarSize == 16 && Subtarget.hasFP16()) || ScalarSize == 32 ||
- ScalarSize >= 64)
- return SDValue();
+ ScalarSize >= 64) {
+ if (ScalarSize != 32 || VT.getScalarSizeInBits() != 16 ||
+ Subtarget.hasFP16())
+ return SDValue();
+ // UINT_TO_FP(vXi32 to vXf16) -> FP_ROUND(UINT_TO_FP(vXi32 to vXf32), 0)
+ return DAG.getNode(
+ ISD::FP_ROUND, SDLoc(N), VT,
+ DAG.getNode(ISD::UINT_TO_FP, SDLoc(N),
+ InVT.changeVectorElementType(MVT::f32), Op0),
+ DAG.getTargetConstant(
+ 0, SDLoc(N),
+ DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout())));
+ }
SDLoc dl(N);
EVT DstVT =
EVT::getVectorVT(*DAG.getContext(),
|
@RKSimon @phoebewang @e-kud can you please review? |
@abhishek-kaushik22 any tests? |
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.
I'd prefer this was handled in VectorLegalizer::ExpandUINT_TO_FLOAT since the issue isn't x86-specific
Can you please provide an example for other targets that this is failing on? |
10fb587
to
9f62f41
Compare
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.
test cases?
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.
Needs tests
With
in the assembly. Thanks @phoebewang for the comments. |
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 one nit.
Thanks @abhishek-kaushik22 ! |
Closes #121793