[PATCH] D29107: Fix a bug when unswitching on partial LIV for SwitchInst

Xin Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 18 22:24:45 PST 2017


trentxintong added inline comments.


================
Comment at: lib/Transforms/Scalar/LoopUnswitch.cpp:1338
     BasicBlock *SISucc = DeadCase.getCaseSuccessor();
     BasicBlock *Latch = L->getLoopLatch();
 
----------------
sanjoy wrote:
> This bit is new right?  Let's do this change in a different commit and go with the bailout on a default switch case in `FindLIVLoopCondition` in the first step (but please add a FIXME to `FindLIVLoopCondition`).
Actually this change is necessary to make the patch work. When I first wrote this patch to solve the problem, I was disabling walking up the operator chain for switches. And this would work and I manually checked the test case worked.

Then we changed the patch to move up the chain and now the problem is: If we have a chain of ands and we have a partial LIV on top of the chain, we will not get to BranchesInfo.setUnswitched(SI, Val); here. Because the SwitchInst is not a direct user of the partial LIV. 

What i did is to move this setUnswitched out to where SwitchInst is unswitched, i.e. in TrivialUnswitching and NonTrivialUnswitching. And with that we can record what is unswitched. I also added more checks into the test cases to make sure unswitching only happen once.



https://reviews.llvm.org/D29107





More information about the llvm-commits mailing list