[llvm-commits] PATCH: instcombine switch on select of constants to br

Nick Lewycky nicholas at mxc.ca
Sun Feb 27 19:01:47 PST 2011


Frits van Bommel wrote:
> Since there has been no progress here for over six weeks, I updated
> this patch myself.
> Does anyone mind if I commit this version?

I kinda wish it didn't work this way. Here's what I have in mind:
   1. fix llvm.org/PR774 (make the default case optional)
   2. one optimization which finds switches that have two destinations 
and turns them into branches
   3. one optimization which sees select (and other things) feeding into 
a switch and removes the impossible cases from the switch, possibly 
including the default case.

That said, if I can't talk you into doing that much work, then this 
patch looks fine:

@@ -2357,10 +2382,10 @@
      return true;
    }

-  if (SelectInst *SI = dyn_cast<SelectInst>(IBI->getAddress())) {
+  if (SelectInst *SI = dyn_cast<SelectInst>(IBI->getAddress()))
      if (SimplifyIndirectBrOnSelect(IBI, SI))
        return SimplifyCFG(BB) | true;
-  }
+
    return Changed;
  }

You didn't change any behaviour here? Just leave that out of the commit.

Nick



More information about the llvm-commits mailing list