[llvm] [TTI][RISCV][SLP] Add IdentityConstantValue option to OperandValueKind for use by SLP and RISCV (PR #228630)

Ryan Buchner via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 11:39:22 PDT 2026


================
@@ -13674,10 +13671,16 @@ TTI::OperandValueInfo BoUpSLP::getOperandInfo(ArrayRef<Value *> Ops) const {
       return CI->getValue().isNegatedPowerOf2();
     return false;
   });
+  const bool IsIdentity = all_of(enumerate(Ops), [&](const auto &Data) {
+    auto *CI = llvm::dyn_cast<llvm::ConstantInt>(Data.value());
+    return CI && CI->getLimitedValue() == Data.index();
+  });
 
   TTI::OperandValueKind VK = TTI::OK_AnyValue;
   if (IsConstant && IsUniform)
     VK = TTI::OK_UniformConstantValue;
+  else if (IsIdentity)
+    VK = TTI::OK_IdentityConstantValue;
----------------
bababuck wrote:

This shouldn't affect uniform values though. The identity case is (0, 1, 2, ...) which only overlaps with the uniform constant case for a `<1 x iXX>` vector. In that case, the implementation lets `TTI::OK_IdentityConstantValue` take priority so shouldn't regress.

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


More information about the llvm-commits mailing list