| OLD | NEW |
| 1 //===- subzero/src/IceSwitchLowering.cpp - Switch lowering ----------------===// | 1 //===- subzero/src/IceSwitchLowering.cpp - Switch lowering ----------------===// |
| 2 // | 2 // |
| 3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 /// | 9 /// |
| 10 /// \file | 10 /// \file |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 // TODO(ascull): Merge in a cycle i.e. -1(=UINTXX_MAX) to 0. This depends on | 49 // TODO(ascull): Merge in a cycle i.e. -1(=UINTXX_MAX) to 0. This depends on |
| 50 // the types for correct wrap around behavior. | 50 // the types for correct wrap around behavior. |
| 51 | 51 |
| 52 // A small number of cases is more efficient without a jump table | 52 // A small number of cases is more efficient without a jump table |
| 53 if (CaseClusters.size() < Func->getTarget()->getMinJumpTableSize()) | 53 if (CaseClusters.size() < Func->getTarget()->getMinJumpTableSize()) |
| 54 return CaseClusters; | 54 return CaseClusters; |
| 55 | 55 |
| 56 // Test for a single jump table. This can be done in constant time whereas | 56 // Test for a single jump table. This can be done in constant time whereas |
| 57 // finding the best set of jump table would be quadratic, too slow(?). If | 57 // finding the best set of jump table would be quadratic, too slow(?). If |
| 58 // jump tables were included in the search tree we'd first have to traverse to | 58 // jump tables were included in the search tree we'd first have to traverse |
| 59 // them. Ideally we would have an unbalanced tree which is biased towards | 59 // to them. Ideally we would have an unbalanced tree which is biased towards |
| 60 // frequently executed code but we can't do this well without profiling data. | 60 // frequently executed code but we can't do this well without profiling data. |
| 61 // So, this single jump table is a good starting point where you can get to | 61 // So, this single jump table is a good starting point where you can get to |
| 62 // the jump table quickly without figuring out how to unbalance the tree. | 62 // the jump table quickly without figuring out how to unbalance the tree. |
| 63 uint64_t MaxValue = CaseClusters.back().High; | 63 uint64_t MaxValue = CaseClusters.back().High; |
| 64 uint64_t MinValue = CaseClusters.front().Low; | 64 uint64_t MinValue = CaseClusters.front().Low; |
| 65 // Don't +1 yet to avoid (INT64_MAX-0)+1 overflow | 65 // Don't +1 yet to avoid (INT64_MAX-0)+1 overflow |
| 66 uint64_t TotalRange = MaxValue - MinValue; | 66 uint64_t TotalRange = MaxValue - MinValue; |
| 67 | 67 |
| 68 // Might be too sparse for the jump table | 68 // Might be too sparse for the jump table |
| 69 if (NumCases * 2 <= TotalRange) | 69 if (NumCases * 2 <= TotalRange) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 94 | 94 |
| 95 bool CaseCluster::tryAppend(const CaseCluster &New) { | 95 bool CaseCluster::tryAppend(const CaseCluster &New) { |
| 96 // Can only append ranges with the same target and are adjacent | 96 // Can only append ranges with the same target and are adjacent |
| 97 bool CanAppend = this->Target == New.Target && this->High + 1 == New.Low; | 97 bool CanAppend = this->Target == New.Target && this->High + 1 == New.Low; |
| 98 if (CanAppend) | 98 if (CanAppend) |
| 99 this->High = New.High; | 99 this->High = New.High; |
| 100 return CanAppend; | 100 return CanAppend; |
| 101 } | 101 } |
| 102 | 102 |
| 103 } // end of namespace Ice | 103 } // end of namespace Ice |
| OLD | NEW |