[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


================
@@ -0,0 +1,53 @@
+//===-- ByteProvider.cpp -------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/CodeGen/ByteProvider.h"
+#include "llvm/CodeGen/SelectionDAGNodes.h"
+
+using namespace llvm;
+
+ByteProvider ByteProvider::getSrc(SDValue Val, int64_t ByteOffset,
+                                  int64_t VectorOffset) {
+  return ByteProvider(Val.getNode(), Val.getResNo(), ByteOffset, VectorOffset);
+}
+
+SDValue ByteProvider::getSrc() const { return SDValue(Node, ResNo); }
+
+std::optional<ByteProvider>
+llvm::calculateByteProviderForOr(SDValue Op, unsigned Index,
+                                 SDByteProviderRecurseFn Recurse) {
+  std::optional<ByteProvider> LHS = Recurse(Op.getOperand(0), Index);
+  if (!LHS)
+    return std::nullopt;
+  std::optional<ByteProvider> RHS = Recurse(Op.getOperand(1), Index);
+  if (!RHS)
+    return std::nullopt;
----------------
arsenm wrote:

```suggestion
  std::optional<ByteProvider> RHS = Recurse(Op.getOperand(1), Index);
  if (!RHS)
    return std::nullopt;
  std::optional<ByteProvider> LHS = Recurse(Op.getOperand(0), Index);
  if (!LHS)
    return std::nullopt;
```

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


More information about the llvm-commits mailing list