[SelectionDAG] Add SPLAT_VECTOR to SelectionDAG::isConstantFPBuildVectorOrConstantFP.

Matches what is done for the int version.

Reviewed By: sdesmalen

Differential Revision: https://reviews.llvm.org/D119793
This commit is contained in:
Craig Topper 2022-02-16 09:13:01 -08:00
parent f150d295da
commit 1daa66d3fd
2 changed files with 26 additions and 0 deletions

View File

@ -11117,6 +11117,10 @@ SDNode *SelectionDAG::isConstantFPBuildVectorOrConstantFP(SDValue N) const {
if (ISD::isBuildVectorOfConstantFPSDNodes(N.getNode()))
return N.getNode();
if ((N.getOpcode() == ISD::SPLAT_VECTOR) &&
isa<ConstantFPSDNode>(N.getOperand(0)))
return N.getNode();
return nullptr;
}

View File

@ -109,3 +109,25 @@ define <vscale x 8 x i16> @combine_vec_lshr_lshr(<vscale x 8 x i16> %x) {
%v2 = lshr <vscale x 8 x i16> %v1, %splat2
ret <vscale x 8 x i16> %v2
}
; fold (fmul x, 1.0) -> x
define <vscale x 2 x float> @combine_fmul_one(<vscale x 2 x float> %x) {
; CHECK-LABEL: combine_fmul_one:
; CHECK: # %bb.0:
; CHECK-NEXT: ret
%ins = insertelement <vscale x 2 x float> poison, float 1.0, i32 0
%splat = shufflevector <vscale x 2 x float> %ins, <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
%v = fmul <vscale x 2 x float> %x, %splat
ret <vscale x 2 x float> %v
}
; fold (fmul 1.0, x) -> x
define <vscale x 2 x float> @combine_fmul_one_commuted(<vscale x 2 x float> %x) {
; CHECK-LABEL: combine_fmul_one_commuted:
; CHECK: # %bb.0:
; CHECK-NEXT: ret
%ins = insertelement <vscale x 2 x float> poison, float 1.0, i32 0
%splat = shufflevector <vscale x 2 x float> %ins, <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer
%v = fmul <vscale x 2 x float> %splat, %x
ret <vscale x 2 x float> %v
}