[llvm] 55dd475 - [X86] Fold (v2i64 (scalar_to_vector (i64 (bitcast (double))))) -> (bitcast (v2f64 scalar_to_vector))
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 29 04:31:22 PST 2024
Author: Simon Pilgrim
Date: 2024-11-29T12:30:55Z
New Revision: 55dd475d1d89db5cd23534a4d9b200854410703d
URL: https://github.com/llvm/llvm-project/commit/55dd475d1d89db5cd23534a4d9b200854410703d
DIFF: https://github.com/llvm/llvm-project/commit/55dd475d1d89db5cd23534a4d9b200854410703d.diff
LOG: [X86] Fold (v2i64 (scalar_to_vector (i64 (bitcast (double))))) -> (bitcast (v2f64 scalar_to_vector))
This can occur more frequently after the MMX retirement if anyone is still using MMX intrinsics that now wrap to SSE
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/mmx-cvt.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 96b03feaa45803..d015870043b0bb 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -58359,10 +58359,16 @@ static SDValue combineScalarToVector(SDNode *N, SelectionDAG &DAG,
DAG.getZExtOrTrunc(ZeroExt, DL, MVT::i32))));
}
- // Combine (v2i64 (scalar_to_vector (i64 (bitconvert (mmx))))) to MOVQ2DQ.
- if (VT == MVT::v2i64 && Src.getOpcode() == ISD::BITCAST &&
- Src.getOperand(0).getValueType() == MVT::x86mmx)
- return DAG.getNode(X86ISD::MOVQ2DQ, DL, VT, Src.getOperand(0));
+ if (VT == MVT::v2i64 && Src.getOpcode() == ISD::BITCAST) {
+ SDValue SrcOp = Src.getOperand(0);
+ // Combine (v2i64 (scalar_to_vector (i64 (bitcast (double))))) to MOVQ.
+ if (SrcOp.getValueType() == MVT::f64)
+ return DAG.getBitcast(
+ VT, DAG.getNode(ISD::SCALAR_TO_VECTOR, DL, MVT::v2f64, SrcOp));
+ // Combine (v2i64 (scalar_to_vector (i64 (bitcast (mmx))))) to MOVQ2DQ.
+ if (SrcOp.getValueType() == MVT::x86mmx)
+ return DAG.getNode(X86ISD::MOVQ2DQ, DL, VT, SrcOp);
+ }
// See if we're broadcasting the scalar value, in which case just reuse that.
// Ensure the same SDValue from the SDNode use is being used.
diff --git a/llvm/test/CodeGen/X86/mmx-cvt.ll b/llvm/test/CodeGen/X86/mmx-cvt.ll
index fac886080587f6..07e56a9148cf01 100644
--- a/llvm/test/CodeGen/X86/mmx-cvt.ll
+++ b/llvm/test/CodeGen/X86/mmx-cvt.ll
@@ -287,8 +287,7 @@ define noundef <2 x i64> @cvt_f64_v2i64(double %a0) {
;
; X64-LABEL: cvt_f64_v2i64:
; X64: # %bb.0:
-; X64-NEXT: movq %xmm0, %rax
-; X64-NEXT: movq %rax, %xmm0
+; X64-NEXT: movq {{.*#+}} xmm0 = xmm0[0],zero
; X64-NEXT: retq
%bc = bitcast double %a0 to <1 x i64>
%r = shufflevector <1 x i64> %bc, <1 x i64> zeroinitializer, <2 x i32> <i32 0, i32 1>
More information about the llvm-commits
mailing list