[PATCH] D119793: [SelectionDAG] Add SPLAT_VECTOR to SelectionDAG::isConstantFPBuildVectorOrConstantFP.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 15 11:37:41 PST 2022
craig.topper updated this revision to Diff 408982.
craig.topper added a comment.
Herald added subscribers: pcwang-thead, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, MaskRay, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
Add test case for simplifying fmul with 1.0.
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
@@ -11107,6 +11107,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.408982.patch
Type: text/x-patch
Size: 1719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220215/101e003a/attachment.bin>
More information about the llvm-commits
mailing list