From 4592bb71954707eda04ee9cc09df84217e5f3bd5 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Wed, 5 Feb 2020 12:32:25 +0000 Subject: [PATCH] visitINSERT_VECTOR_ELT - pull out repeated dyn_cast. NFCI. This always gets called at least once. --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index f8b90ae6274a..9625134eae78 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -16900,11 +16900,11 @@ SDValue DAGCombiner::visitINSERT_VECTOR_ELT(SDNode *N) { EVT VT = InVec.getValueType(); unsigned NumElts = VT.getVectorNumElements(); + auto *IndexC = dyn_cast(EltNo); // Insert into out-of-bounds element is undefined. - if (auto *IndexC = dyn_cast(EltNo)) - if (IndexC->getZExtValue() >= VT.getVectorNumElements()) - return DAG.getUNDEF(VT); + if (IndexC && IndexC->getZExtValue() >= VT.getVectorNumElements()) + return DAG.getUNDEF(VT); // Remove redundant insertions: // (insert_vector_elt x (extract_vector_elt x idx) idx) -> x @@ -16912,7 +16912,6 @@ SDValue DAGCombiner::visitINSERT_VECTOR_ELT(SDNode *N) { InVec == InVal.getOperand(0) && EltNo == InVal.getOperand(1)) return InVec; - auto *IndexC = dyn_cast(EltNo); if (!IndexC) { // If this is variable insert to undef vector, it might be better to splat: // inselt undef, InVal, EltNo --> build_vector < InVal, InVal, ... >