[llvm] [AMDGPU][InstCombine] Optimize constant shuffle patterns (PR #192246)

Robert Imschweiler via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 07:46:06 PDT 2026


================
@@ -718,6 +720,288 @@ GCNTTIImpl::hoistLaneIntrinsicThroughOperand(InstCombiner &IC,
   return nullptr;
 }
 
+static std::optional<unsigned> evalLaneExpr(Value *V, unsigned Lane,
+                                            const GCNSubtarget &ST,
+                                            const DataLayout &DL,
+                                            unsigned Depth = 0) {
+  if (Depth > 16)
+    return std::nullopt;
+
+  if (isThreadID(ST, V))
+    return Lane;
+
+  if (const auto *CI = dyn_cast<ConstantInt>(V))
+    return CI->getZExtValue();
+
+  auto *BO = dyn_cast<BinaryOperator>(V);
+  if (!BO)
+    return std::nullopt;
+
+  auto LHS = evalLaneExpr(BO->getOperand(0), Lane, ST, DL, Depth + 1);
----------------
ro-i wrote:

shouldn't use auto for Types that are not trivially visible inline (e.g., due to cast, such as in `auto *BB = dyn_cast<BasicBlock>(...)`)

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


More information about the llvm-commits mailing list