[llvm] r344425 - [X86] Improve type legalization of (v2i32/v4i16/v8i16 (bitcast (v2f32))) to avoid a stack stack temporary.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 12 15:00:05 PDT 2018
Author: ctopper
Date: Fri Oct 12 15:00:04 2018
New Revision: 344425
URL: http://llvm.org/viewvc/llvm-project?rev=344425&view=rev
Log:
[X86] Improve type legalization of (v2i32/v4i16/v8i16 (bitcast (v2f32))) to avoid a stack stack temporary.
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/2012-01-18-vbitcast.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=344425&r1=344424&r2=344425&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Oct 12 15:00:04 2018
@@ -26296,7 +26296,7 @@ void X86TargetLowering::ReplaceNodeResul
return;
}
- if (SrcVT != MVT::f64 ||
+ if ((SrcVT != MVT::f64 && SrcVT != MVT::v2f32) ||
(DstVT != MVT::v2i32 && DstVT != MVT::v4i16 && DstVT != MVT::v8i8) ||
getTypeAction(*DAG.getContext(), DstVT) == TypeWidenVector)
return;
@@ -26304,12 +26304,18 @@ void X86TargetLowering::ReplaceNodeResul
unsigned NumElts = DstVT.getVectorNumElements();
EVT SVT = DstVT.getVectorElementType();
EVT WiderVT = EVT::getVectorVT(*DAG.getContext(), SVT, NumElts * 2);
- SDValue Expanded = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl,
- MVT::v2f64, N->getOperand(0));
- SDValue ToVecInt = DAG.getBitcast(WiderVT, Expanded);
- SDValue Extract = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, DstVT,
- ToVecInt, DAG.getIntPtrConstant(0, dl));
- Results.push_back(Extract);
+ SDValue Res;
+ if (SrcVT == MVT::f64)
+ Res = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl,
+ MVT::v2f64, N->getOperand(0));
+ else
+ Res = DAG.getNode(ISD::CONCAT_VECTORS, dl, MVT::v4f32, N->getOperand(0),
+ DAG.getUNDEF(MVT::v2f32));
+
+ Res = DAG.getBitcast(WiderVT, Res);
+ Res = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, DstVT, Res,
+ DAG.getIntPtrConstant(0, dl));
+ Results.push_back(Res);
return;
}
case ISD::MGATHER: {
Modified: llvm/trunk/test/CodeGen/X86/2012-01-18-vbitcast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2012-01-18-vbitcast.ll?rev=344425&r1=344424&r2=344425&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2012-01-18-vbitcast.ll (original)
+++ llvm/trunk/test/CodeGen/X86/2012-01-18-vbitcast.ll Fri Oct 12 15:00:04 2018
@@ -4,17 +4,10 @@
define <2 x i32> @vcast(<2 x float> %a, <2 x float> %b) {
; CHECK-LABEL: vcast:
; CHECK: # %bb.0:
-; CHECK-NEXT: subq $16, %rsp
-; CHECK-NEXT: .seh_stackalloc 16
-; CHECK-NEXT: .seh_endprologue
-; CHECK-NEXT: pmovzxdq {{.*#+}} xmm1 = mem[0],zero,mem[1],zero
; CHECK-NEXT: pmovzxdq {{.*#+}} xmm0 = mem[0],zero,mem[1],zero
+; CHECK-NEXT: pmovzxdq {{.*#+}} xmm1 = mem[0],zero,mem[1],zero
; CHECK-NEXT: psubq %xmm1, %xmm0
-; CHECK-NEXT: addq $16, %rsp
; CHECK-NEXT: retq
-; CHECK-NEXT: .seh_handlerdata
-; CHECK-NEXT: .text
-; CHECK-NEXT: .seh_endproc
%af = bitcast <2 x float> %a to <2 x i32>
%bf = bitcast <2 x float> %b to <2 x i32>
%x = sub <2 x i32> %af, %bf
More information about the llvm-commits
mailing list