[llvm] [X86] Combine `uitofp <v x i32> to <v x half>` (PR #121809)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 6 09:52:26 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: None (abhishek-kaushik22)
<details>
<summary>Changes</summary>
Closes #<!-- -->121793
---
Full diff: https://github.com/llvm/llvm-project/pull/121809.diff
1 Files Affected:
- (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+13-2)
``````````diff
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(),
``````````
</details>
https://github.com/llvm/llvm-project/pull/121809
More information about the llvm-commits
mailing list