diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 4a8dd95837d..731fb9968c4 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1684,6 +1684,11 @@ bool isOneOrOneSplat(SDValue V, bool AllowUndefs = false); /// Does not permit build vector implicit truncation. bool isAllOnesOrAllOnesSplat(SDValue V, bool AllowUndefs = false); +/// Return true if \p V is either a integer or FP constant. +inline bool isIntOrFPConstant(SDValue V) { + return isa(V) || isa(V); +} + class GlobalAddressSDNode : public SDNode { friend class SelectionDAG; diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index e5112cdcd41..e280f3dd37e 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -12413,7 +12413,7 @@ SDValue DAGCombiner::visitBITCAST(SDNode *N) { VT.getVectorElementType()); // If the input is a constant, let getNode fold it. - if (isa(N0) || isa(N0)) { + if (isIntOrFPConstant(N0)) { // If we can't allow illegal operations, we need to check that this is just // a fp -> int or int -> conversion and that the resulting operation will // be legal. @@ -12651,7 +12651,7 @@ SDValue DAGCombiner::visitFREEZE(SDNode *N) { return N0; // If the input is a constant, return it. - if (isa(N0) || isa(N0)) + if (isIntOrFPConstant(N0)) return N0; return SDValue(); @@ -16912,7 +16912,7 @@ void DAGCombiner::getStoreMergeCandidates( case StoreSource::Constant: if (NoTypeMatch) return false; - if (!(isa(OtherBC) || isa(OtherBC))) + if (!isIntOrFPConstant(OtherBC)) return false; break; case StoreSource::Extract: @@ -20492,7 +20492,7 @@ static SDValue combineShuffleOfScalars(ShuffleVectorSDNode *SVN, // generating a splat; semantically, this is fine, but it's likely to // generate low-quality code if the target can't reconstruct an appropriate // shuffle. - if (!Op.isUndef() && !isa(Op) && !isa(Op)) + if (!Op.isUndef() && !isIntOrFPConstant(Op)) if (!IsSplat && !DuplicateOps.insert(Op).second) return SDValue(); diff --git a/lib/Target/AArch64/AArch64ISelLowering.cpp b/lib/Target/AArch64/AArch64ISelLowering.cpp index a40db7e10f4..6497d8e9f05 100644 --- a/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -9680,10 +9680,10 @@ SDValue AArch64TargetLowering::LowerBUILD_VECTOR(SDValue Op, } if (i > 0) isOnlyLowElement = false; - if (!isa(V) && !isa(V)) + if (!isIntOrFPConstant(V)) isConstant = false; - if (isa(V) || isa(V)) { + if (isIntOrFPConstant(V)) { ++NumConstantLanes; if (!ConstantValue.getNode()) ConstantValue = V; @@ -9849,7 +9849,7 @@ SDValue AArch64TargetLowering::LowerBUILD_VECTOR(SDValue Op, for (unsigned i = 0; i < NumElts; ++i) { SDValue V = Op.getOperand(i); SDValue LaneIdx = DAG.getConstant(i, dl, MVT::i64); - if (!isa(V) && !isa(V)) + if (!isIntOrFPConstant(V)) // Note that type legalization likely mucked about with the VT of the // source operand, so we may have to convert it here before inserting. Val = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, VT, Val, V, LaneIdx);