[llvm] [LV] Support generating masks for switch terminators. (PR #99808)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 11 07:24:41 PDT 2024


================
@@ -6456,6 +6456,17 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
     // a predicated block since it will become a fall-through, although we
     // may decide in the future to call TTI for all branches.
   }
+  case Instruction::Switch: {
+    if (VF.isScalar())
+      return TTI.getCFInstrCost(Instruction::Switch, CostKind);
----------------
fhahn wrote:

The vector code matches the cost of the generated masks, which h are costed explicitly for the version with branches due to the compares being explicit instructions. Currently it seems more like the scalar cost may be estimated by getCFInstrCost, but that probably would need to be fixed in TTI.

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


More information about the llvm-commits mailing list