[llvm] [AMDGPU][InstCombine] Optimize constant shuffle patterns (PR #192246)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 16 07:49:12 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);
+ auto RHS = evalLaneExpr(BO->getOperand(1), Lane, ST, DL, Depth + 1);
+ if (!LHS || !RHS)
----------------
arsenm wrote:
Early exit aft the first failure
https://github.com/llvm/llvm-project/pull/192246
More information about the llvm-commits
mailing list