diff options
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 10 | 
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 66b6024..3a04ee1 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -1727,7 +1727,8 @@ void SelectionDAGBuilder::visitBitTestCase(BitTestBlock &BB,    SDValue ShiftOp = DAG.getCopyFromReg(getControlRoot(), getCurDebugLoc(),                                         Reg, VT);    SDValue Cmp; -  if (CountPopulation_64(B.Mask) == 1) { +  unsigned PopCount = CountPopulation_64(B.Mask); +  if (PopCount == 1) {      // Testing for a single bit; just compare the shift count with what it      // would need to be to shift a 1 bit in that position.      Cmp = DAG.getSetCC(getCurDebugLoc(), @@ -1735,6 +1736,13 @@ void SelectionDAGBuilder::visitBitTestCase(BitTestBlock &BB,                         ShiftOp,                         DAG.getConstant(CountTrailingZeros_64(B.Mask), VT),                         ISD::SETEQ); +  } else if (PopCount == BB.Range) { +    // There is only one zero bit in the range, test for it directly. +    Cmp = DAG.getSetCC(getCurDebugLoc(), +                       TLI.getSetCCResultType(VT), +                       ShiftOp, +                       DAG.getConstant(CountTrailingOnes_64(B.Mask), VT), +                       ISD::SETNE);    } else {      // Make desired shift      SDValue SwitchVal = DAG.getNode(ISD::SHL, getCurDebugLoc(), VT,  | 
