[llvm] 0bbe953 - [X86] Fold extract_subvector(cvtps2dq(x),c) -> cvtps2dq(extract_subvector(x,c))
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 03:06:49 PDT 2024
Author: Simon Pilgrim
Date: 2024-04-09T11:06:18+01:00
New Revision: 0bbe953aa3289a32cd816647820c8676bb3a61bc
URL: https://github.com/llvm/llvm-project/commit/0bbe953aa3289a32cd816647820c8676bb3a61bc
DIFF: https://github.com/llvm/llvm-project/commit/0bbe953aa3289a32cd816647820c8676bb3a61bc.diff
LOG: [X86] Fold extract_subvector(cvtps2dq(x),c) -> cvtps2dq(extract_subvector(x,c))
Help unblock #83402
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/vector-half-conversions.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index f24e0fc25faccc..d4d7b29596636d 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -56158,6 +56158,13 @@ static SDValue combineEXTRACT_SUBVECTOR(SDNode *N, SelectionDAG &DAG,
return DAG.getNode(X86ISD::VFPEXT, DL, VT, InVec.getOperand(0));
}
}
+ // v4i32 CVTPS2DQ(v4f32).
+ if (InOpcode == ISD::FP_TO_SINT && VT == MVT::v4i32) {
+ SDValue Src = InVec.getOperand(0);
+ if (Src.getValueType().getScalarType() == MVT::f32)
+ return DAG.getNode(InOpcode, DL, VT,
+ extractSubVector(Src, IdxVal, DAG, DL, SizeInBits));
+ }
if (IdxVal == 0 &&
(ISD::isExtOpcode(InOpcode) || ISD::isExtVecInRegOpcode(InOpcode)) &&
(SizeInBits == 128 || SizeInBits == 256) &&
diff --git a/llvm/test/CodeGen/X86/vector-half-conversions.ll b/llvm/test/CodeGen/X86/vector-half-conversions.ll
index 563cf016501340..a360cf8ca83d03 100644
--- a/llvm/test/CodeGen/X86/vector-half-conversions.ll
+++ b/llvm/test/CodeGen/X86/vector-half-conversions.ll
@@ -5025,16 +5025,14 @@ define <4 x i32> @fptosi_4f16_to_4i32(<4 x half> %a) nounwind {
; F16C-LABEL: fptosi_4f16_to_4i32:
; F16C: # %bb.0:
; F16C-NEXT: vcvtph2ps %xmm0, %ymm0
-; F16C-NEXT: vcvttps2dq %ymm0, %ymm0
-; F16C-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
+; F16C-NEXT: vcvttps2dq %xmm0, %xmm0
; F16C-NEXT: vzeroupper
; F16C-NEXT: retq
;
; AVX512-LABEL: fptosi_4f16_to_4i32:
; AVX512: # %bb.0:
; AVX512-NEXT: vcvtph2ps %xmm0, %ymm0
-; AVX512-NEXT: vcvttps2dq %ymm0, %ymm0
-; AVX512-NEXT: # kill: def $xmm0 killed $xmm0 killed $ymm0
+; AVX512-NEXT: vcvttps2dq %xmm0, %xmm0
; AVX512-NEXT: vzeroupper
; AVX512-NEXT: retq
%cvt = fptosi <4 x half> %a to <4 x i32>
More information about the llvm-commits
mailing list