[llvm] [RISCV][TTI] Add instruction cost for vp.select. (PR #109381)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 20 06:24:48 PDT 2024


================
@@ -1065,6 +1065,13 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
         *FOp, ICA.getArgTypes()[0], UI->getPointerAlignment(),
         UI->getOperand(1)->getType()->getPointerAddressSpace(), CostKind);
   }
+  case Intrinsic::vp_select: {
+    Intrinsic::ID IID = ICA.getID();
+    std::optional<unsigned> FOp = VPIntrinsic::getFunctionalOpcodeForVP(IID);
+    assert(FOp.has_value());
----------------
tschuett wrote:

It seems to be a common pattern, but you cannot assert that an optional has a value.
```
if (FOp) {
 return getCmpSelInstrCost(*FOp, ICA.getReturnType(), ICA.getArgTypes()[0],
                              CmpInst::BAD_ICMP_PREDICATE, CostKind);
} {
 // I don't know
}
```

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


More information about the llvm-commits mailing list