[PATCH] D27999: DAG: Add helper for testing constant values
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 20 13:45:47 PST 2016
LGTM.
Matt Arsenault via Phabricator <reviews at reviews.llvm.org> writes:
> arsenm created this revision.
> arsenm added a reviewer: bogner.
> arsenm added a subscriber: llvm-commits.
> Herald added a subscriber: wdng.
>
> There are helpers for testing for constant or constant build_vector,
> and for splat ConstantFP vectors, but not for a constantfp or
> non-splat ConstantFP vector.
>
>
> https://reviews.llvm.org/D27999
>
> Files:
> include/llvm/CodeGen/SelectionDAG.h
> lib/CodeGen/SelectionDAG/SelectionDAG.cpp
>
>
> Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> ===================================================================
> --- lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> +++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp
> @@ -7517,6 +7517,16 @@
> return nullptr;
> }
>
> +SDNode *SelectionDAG::isConstantFPBuildVectorOrConstantFP(SDValue N) {
> + if (isa<ConstantFPSDNode>(N))
> + return N.getNode();
> +
> + if (ISD::isBuildVectorOfConstantFPSDNodes(N.getNode()))
> + return N.getNode();
> +
> + return nullptr;
> +}
> +
> #ifndef NDEBUG
> static void checkForCyclesHelper(const SDNode *N,
> SmallPtrSetImpl<const SDNode*> &Visited,
> Index: include/llvm/CodeGen/SelectionDAG.h
> ===================================================================
> --- include/llvm/CodeGen/SelectionDAG.h
> +++ include/llvm/CodeGen/SelectionDAG.h
> @@ -1362,6 +1362,16 @@
> /// Test whether the given value is a constant int or similar node.
> SDNode *isConstantIntBuildVectorOrConstantInt(SDValue N);
>
> + /// Test whether the given value is a constant FP or similar node.
> + SDNode *isConstantFPBuildVectorOrConstantFP(SDValue N);
> +
> + /// \returns true if \p V is any kind of constant or build_vector of
> + /// constants, int or float. If a vector, it may not necessarily be a splat.
> + inline bool isConstantValueOfAnyType(SDValue N) {
> + return isConstantIntBuildVectorOrConstantInt(N) ||
> + isConstantFPBuildVectorOrConstantFP(N);
> + }
> +
> private:
> void InsertNode(SDNode *N);
> bool RemoveNodeFromCSEMaps(SDNode *N);
>
>
More information about the llvm-commits
mailing list