Skip to content

Commit 9c05908

Browse files
Apply suggestion from @bashbaug
Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
1 parent eaf39c2 commit 9c05908

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

test_conformance/integer_ops/test_extended_bit_ops_insert.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ cpu_bit_insert(T tbase, T tinsert, cl_uint offset, cl_uint count)
3535
cl_ulong base = static_cast<cl_ulong>(tbase);
3636
cl_ulong insert = static_cast<cl_ulong>(tinsert);
3737

38-
cl_ulong mask = 0;
38+
cl_ulong result = base;
3939
if (offset < 64)
40-
mask = (count < 64) ? ((1ULL << count) - 1) << offset : ~0ULL;
41-
cl_ulong shifted = 0;
42-
if (offset < 64) shifted = (insert << offset);
43-
cl_ulong result = (shifted & mask) | (base & ~mask);
40+
{
41+
cl_ulong mask = (count < 64) ? ((1ULL << count) - 1) << offset : ~0ULL;
42+
result = ((insert << offset) & mask) | (base & ~mask);
43+
}
4444

4545
return static_cast<typename std::make_unsigned<T>::type>(result);
4646
}

0 commit comments

Comments
 (0)