[llvm] [LV] Convert scatter w/uniform addr and mask being header mask to scalar store. (PR #172799)

Elvis Wang via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 22:46:02 PDT 2026


================
@@ -1114,6 +1114,57 @@ Value *VPInstruction::generate(VPTransformState &State) {
   }
 }
 
+InstructionCost VPInstruction::getCostForRecipeWithOpcodeAndTypes(
+    unsigned Opcode, Type *ValTy, Instruction *I, ElementCount VF,
+    VPCostContext &Ctx) {
+  switch (Opcode) {
+  case VPInstruction::LastActiveLane: {
+    // LastActiveLane computes the index of the last active lane in a
+    // predicate mask: NOT + cttz_elts + SUB.
+    if (VF.isScalar())
+      return Ctx.TTI.getCmpSelInstrCost(Instruction::ICmp, ValTy,
+                                        CmpInst::makeCmpResultType(ValTy),
+                                        CmpInst::ICMP_EQ, Ctx.CostKind);
+    auto *PredTy = toVectorTy(ValTy, VF);
+    IntrinsicCostAttributes Attrs(Intrinsic::experimental_cttz_elts,
+                                  Type::getInt64Ty(Ctx.LLVMCtx),
----------------
ElvisWang123 wrote:

Update to result type (index type) and added tests. Thanks!

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


More information about the llvm-commits mailing list