[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 01:00:36 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:

How so? Cases the were previously `TTI::OK_NonUniformConstantValue` will now be replace with `TTI::OK_IdentityConstantValue`. Targets should be using the API function `OperandValueInfo::isConstant()` rather than directly checking for `TTI::OK_NonUniformConstantValue`.

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


More information about the llvm-commits mailing list