diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h --- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1684,6 +1684,11 @@ /// 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/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -12413,7 +12413,7 @@ 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 @@ 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 @@ 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 @@ // 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/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -9680,10 +9680,10 @@ } 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 @@ 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);