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

via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 24 09:14:11 PDT 2024


================
@@ -7763,6 +7763,41 @@ VPValue *VPRecipeBuilder::createEdgeMask(BasicBlock *Src, BasicBlock *Dst) {
 
   VPValue *SrcMask = getBlockInMask(Src);
 
+  if (auto *SI = dyn_cast<SwitchInst>(Src->getTerminator())) {
+    // Create mask where the terminator in Src is a switch. We need to handle 2
+    // separate cases:
+    // 1. Dst is not the default desintation. Dst is reached if any of the cases
+    // with destination == Dst are taken. Join the conditions for each case
+    // where destination == Dst using a logical OR.
+    // 2. Dst is the default destination. Dst is reached if none of the cases
+    // with destination != Dst are taken. Join the conditions for each case
+    // where the destination is != Dst using a logical OR and negate it.
----------------
ayalz wrote:

Cases whose destinations are the same as default are redundant and can be ignored/eliminated - they will get there anyhow. Perhaps slightly clearer to filter them as such during the traversal.

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


More information about the cfe-commits mailing list