[llvm] a5f5634 - [DAG] narrowExtractedVectorLoad - EXTRACT_SUBVECTOR indices are always constant

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 22 10:32:37 PDT 2021


Author: Simon Pilgrim
Date: 2021-10-22T18:32:14+01:00
New Revision: a5f56342b01765e33abbae97e087f93041a39353

URL: https://github.com/llvm/llvm-project/commit/a5f56342b01765e33abbae97e087f93041a39353
DIFF: https://github.com/llvm/llvm-project/commit/a5f56342b01765e33abbae97e087f93041a39353.diff

LOG: [DAG] narrowExtractedVectorLoad - EXTRACT_SUBVECTOR indices are always constant

EXTRACT_SUBVECTOR indices are always constant, we don't need to check for ConstantSDNode, we should just use getConstantOperandVal which will assert for the constant.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 24e6ef8e3587..60b78b21aa2a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -20501,9 +20501,7 @@ static SDValue narrowExtractedVectorLoad(SDNode *Extract, SelectionDAG &DAG) {
     return SDValue();
 
   auto *Ld = dyn_cast<LoadSDNode>(Extract->getOperand(0));
-  auto *ExtIdx = dyn_cast<ConstantSDNode>(Extract->getOperand(1));
-  if (!Ld || Ld->getExtensionType() || !Ld->isSimple() ||
-      !ExtIdx)
+  if (!Ld || Ld->getExtensionType() || !Ld->isSimple())
     return SDValue();
 
   // Allow targets to opt-out.
@@ -20513,7 +20511,7 @@ static SDValue narrowExtractedVectorLoad(SDNode *Extract, SelectionDAG &DAG) {
   if (!VT.isByteSized())
     return SDValue();
 
-  unsigned Index = ExtIdx->getZExtValue();
+  unsigned Index = Extract->getConstantOperandVal(1);
   unsigned NumElts = VT.getVectorMinNumElements();
 
   // The definition of EXTRACT_SUBVECTOR states that the index must be a


        


More information about the llvm-commits mailing list