Skip to content

Commit 047f26e

Browse files
authored
Correct log2u in OMSort (#2882)
Signed-off-by: Mike Essenmacher <[email protected]>
1 parent 3dadfa3 commit 047f26e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Runtime/OMSort.inc

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*/
4+
5+
//===-- OMSort.inc - OMSort C/C++ Implementation --===//
6+
//
7+
// Copyright 2023-2024 The IBM Research Authors.
8+
//
9+
// =============================================================================
10+
//
11+
// This file contains C/C++ implementation of OMSort.
12+
//
13+
//===----------------------------------------------------------------------===//
14+
115
#ifdef __cplusplus
216
#include <cassert>
317
#else
@@ -190,8 +204,8 @@ typedef struct indexStack {
190204
static int64_t log2u(uint64_t n) {
191205
assert(n > 0);
192206
int64_t b = 0;
193-
for (; n > 0; b++)
194-
n = n >> 2;
207+
for (; n > 1; b++)
208+
n = n >> 1;
195209
return b;
196210
}
197211

0 commit comments

Comments
 (0)