[llvm] 27708db - [DAGCombiner] convert StoreSource if-chain to switch; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 12:45:14 PDT 2020


Author: Sanjay Patel
Date: 2020-08-17T15:37:54-04:00
New Revision: 27708db3e38d43faf4c4de8550d97dd04bbeea86

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

LOG: [DAGCombiner] convert StoreSource if-chain to switch; NFC

The "isa" checks were less constrained because they allow
target constants, but the later matching code would bail
out on those anyway, so this should be slightly more
efficient.

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 cd2a1eb4b61a..6d8e0de1e847 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -641,14 +641,18 @@ namespace {
     // Classify the origin of a stored value.
     enum class StoreSource { Unknown, Constant, Extract, Load };
     StoreSource getStoreSource(SDValue StoreVal) {
-      if (isa<ConstantSDNode>(StoreVal) || isa<ConstantFPSDNode>(StoreVal))
+      switch (StoreVal.getOpcode()) {
+      case ISD::Constant:
+      case ISD::ConstantFP:
         return StoreSource::Constant;
-      if (StoreVal.getOpcode() == ISD::EXTRACT_VECTOR_ELT ||
-          StoreVal.getOpcode() == ISD::EXTRACT_SUBVECTOR)
+      case ISD::EXTRACT_VECTOR_ELT:
+      case ISD::EXTRACT_SUBVECTOR:
         return StoreSource::Extract;
-      if (isa<LoadSDNode>(StoreVal))
+      case ISD::LOAD:
         return StoreSource::Load;
-      return StoreSource::Unknown;
+      default:
+        return StoreSource::Unknown;
+      }
     }
 
     /// This is a helper function for visitMUL to check the profitability


        


More information about the llvm-commits mailing list