[llvm] [DAGCombiner] Share byte provider steps with AMDGPU target (PR #221959)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 04:10:44 PDT 2026


================
@@ -8,76 +8,81 @@
 //
 // \file
 // This file implements ByteProvider. The purpose of ByteProvider is to provide
-// a map between a target node's byte (byte position is DestOffset) and the
-// source (and byte position) that provides it (in Src and SrcOffset
-// respectively) See CodeGen/SelectionDAG/DAGCombiner.cpp MatchLoadCombine
+// a map between a byte of a target node and the source that provides it.
 //
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_CODEGEN_BYTEPROVIDER_H
 #define LLVM_CODEGEN_BYTEPROVIDER_H
 
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
 #include <optional>
-#include <type_traits>
 
 namespace llvm {
 
+class SDNode;
+class SDValue;
+
 /// Represents known origin of an individual byte in combine pattern. The
 /// value of the byte is either constant zero, or comes from memory /
 /// some other productive instruction (e.g. arithmetic instructions).
 /// Bit manipulation instructions like shifts are not ByteProviders, rather
 /// are used to extract Bytes.
-template <typename ISelOp> class ByteProvider {
+class ByteProvider {
 private:
-  ByteProvider(std::optional<ISelOp> Src, int64_t DestOffset, int64_t SrcOffset)
-      : Src(Src), DestOffset(DestOffset), SrcOffset(SrcOffset) {}
-
-  // TODO -- use constraint in c++20
-  // Does this type correspond with an operation in selection DAG
-  // Only allow classes with member function getOpcode
-  template <typename U>
-  using check_has_getOpcode =
-      decltype(std::declval<std::remove_pointer_t<U> &>().getOpcode());
-
-  template <typename U>
-  static constexpr bool has_getOpcode =
-      is_detected<check_has_getOpcode, U>::value;
+  ByteProvider(SDNode *Node, unsigned ResNo, int64_t DestOffset,
+               int64_t SrcOffset)
+      : Node(Node), ResNo(ResNo), DestOffset(DestOffset), SrcOffset(SrcOffset) {
+  }
 
 public:
-  // For constant zero providers Src is set to nullopt. For actual providers
-  // Src represents the node which originally produced the relevant bits.
-  std::optional<ISelOp> Src = std::nullopt;
-  // DestOffset is the offset of the byte in the dest we are trying to map for.
+  // For constant zero providers Node is null. For actual providers Node and
+  // ResNo represent the SDValue which originally produced the relevant bits.
+  SDNode *Node = nullptr;
+  unsigned ResNo = 0;
----------------
arsenm wrote:

This pair is just SDValue?

https://github.com/llvm/llvm-project/pull/221959


More information about the llvm-commits mailing list