> Next stage into switch lowering refactoring > 1. Fix some bugs in the jump table lowering threshold > 2. Implement much better metric for optimal pivot selection > 3. Tune thresholds for different lowering methods > 4. Implement shift-and trick for lowering small (<machine word > length) cases with few destinations. Good testcase will follow.
Oooh, very cool. > @@ -1484,20 +1593,33 @@ > > uint64_t LSize = FrontCase.size(); > uint64_t RSize = TSize-LSize; > + DOUT << "Selecting best pivot: \n" > + << "First: " << First << ", Last: " << Last <<"\n" > + << "LSize: " << LSize << ", RSize: " << RSize << "\n"; > for (CaseItr I = CR.Range.first, J=I+1, E = CR.Range.second; > J!=E; ++I, ++J) { > int64_t LEnd = cast<ConstantInt>(I->High)->getSExtValue(); > int64_t RBegin = cast<ConstantInt>(J->Low)->getSExtValue(); > + assert((RBegin-LEnd>=1) && "Invalid case distance"); > double LDensity = (double)LSize / (double)((LEnd - First) + > 1ULL); > double RDensity = (double)RSize / (double)((Last - RBegin) + > 1ULL); > - if (Density < (LDensity + RDensity)) { > + double Metric = log(RBegin-LEnd)*(LDensity+RDensity); Is there any metric you can use here other than something based on 'log'? Can you do this determination with integer arithmetic? > @@ -1549,6 +1671,130 @@ > return true; > } > > +/// handleBitTestsSwitchCase - if current case range has few > destination and > +/// range span less, than machine word bitwidth, encode case range > into series > +/// of masks and emit bit tests with these masks. > +bool SelectionDAGLowering::handleBitTestsSwitchCase(CaseRec& CR, > + CaseRecVector& > WorkList, > + Value* SV, > + > MachineBasicBlock* Default) { > + unsigned IntPtrBits = getSizeInBits(TLI.getPointerTy()); ... > + if (range>IntPtrBits || Using intptr here is a good first step. However, some targets has GPR's wider than intptr_t that are efficient (e.g. a ppc64 chip running in ppc32 mode). Overall, very very nice Anton, -Chris _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits