Skip to content
  • Cong Hou's avatar
    cd595913
    Remove the final bit test during lowering switch statement if all cases in bit... · cd595913
    Cong Hou authored
    Remove the final bit test during lowering switch statement if all cases in bit test cover a contiguous range.
    
    When lowering switch statement, if bit tests are used then LLVM will always generates a jump to the default statement in the last bit test. However, this is not necessary when all cases in bit tests cover a contiguous range. This is because when generating the bit tests header MBB, there is a range check that guarantees cases in bit tests won't go outside of [low, high], where low and high are minimum and maximum case values in the bit tests. This patch checks if this is the case and then doesn't emit jump to default statement and hence saves a bit test and a branch.
    
    Differential Revision: http://reviews.llvm.org/D12249
    
    llvm-svn: 245976
    cd595913
    Remove the final bit test during lowering switch statement if all cases in bit...
    Cong Hou authored
    Remove the final bit test during lowering switch statement if all cases in bit test cover a contiguous range.
    
    When lowering switch statement, if bit tests are used then LLVM will always generates a jump to the default statement in the last bit test. However, this is not necessary when all cases in bit tests cover a contiguous range. This is because when generating the bit tests header MBB, there is a range check that guarantees cases in bit tests won't go outside of [low, high], where low and high are minimum and maximum case values in the bit tests. This patch checks if this is the case and then doesn't emit jump to default statement and hence saves a bit test and a branch.
    
    Differential Revision: http://reviews.llvm.org/D12249
    
    llvm-svn: 245976
Loading