[PATCH] D119793: [SelectionDAG] Add SPLAT_VECTOR to SelectionDAG::isConstantFPBuildVectorOrConstantFP.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 16 09:22:38 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1daa66d3fda9: [SelectionDAG] Add SPLAT_VECTOR to SelectionDAG… (authored by craig.topper).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119793/new/
https://reviews.llvm.org/D119793
Files:
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/test/CodeGen/RISCV/rvv/combine-splats.ll
Index: llvm/test/CodeGen/RISCV/rvv/combine-splats.ll
===================================================================
--- llvm/test/CodeGen/RISCV/rvv/combine-splats.ll
+++ llvm/test/CodeGen/RISCV/rvv/combine-splats.ll
@@ -109,3 +109,25 @@
%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
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -11117,6 +11117,10 @@
if (ISD::isBuildVectorOfConstantFPSDNodes(N.getNode()))
return N.getNode();
+ if ((N.getOpcode() == ISD::SPLAT_VECTOR) &&
+ isa<ConstantFPSDNode>(N.getOperand(0)))
+ return N.getNode();
+
return nullptr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119793.409294.patch
Type: text/x-patch
Size: 1719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220216/e744d071/attachment.bin>
More information about the llvm-commits
mailing list