Skip to content

Commit 0866eac

Browse files
author
jgtong
authored
Merge pull request #53 from mmoadeli/unreachable-switch-case
[ethminer] Remove unreachable default case in switch statements to prevent potential performance regression.
2 parents 844f718 + 8c7de43 commit 0866eac

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ethminer/libethash-sycl/dagger_shuffled.dp.hpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ DEV_INLINE bool compute_hash(uint64_t nonce, sycl::uint2 *mix_hash, sycl::nd_ite
8585
shuffle[7].x() = item_ct1.get_sub_group().shuffle(state[7].x(), i + p + iShuffleOffset);
8686
shuffle[7].y() = item_ct1.get_sub_group().shuffle(state[7].y(), i + p + iShuffleOffset);
8787

88+
assert(mix_idx <= 3);
8889

8990
switch (mix_idx) {
9091
case 0:
@@ -96,9 +97,9 @@ DEV_INLINE bool compute_hash(uint64_t nonce, sycl::uint2 *mix_hash, sycl::nd_ite
9697
case 2:
9798
mix[p] = vectorize2(shuffle[4], shuffle[5]);
9899
break;
99-
case 3:
100-
mix[p] = vectorize2(shuffle[6], shuffle[7]);
101-
break;
100+
default:
101+
mix[p] = vectorize2(shuffle[6], shuffle[7]);
102+
break;
102103
}
103104

104105
init0[p] = item_ct1.get_sub_group().shuffle(shuffle[0].x(), iShuffleOffset);
@@ -182,6 +183,7 @@ DEV_INLINE bool compute_hash(uint64_t nonce, sycl::uint2 *mix_hash, sycl::nd_ite
182183
shuffle_7.y() = item_ct1.get_sub_group().shuffle(state[7].y(), i + p + iShuffleOffset);
183184

184185
/////}
186+
assert(mix_idx <= 3);
185187

186188
switch (mix_idx) {
187189
case 0:
@@ -193,9 +195,9 @@ DEV_INLINE bool compute_hash(uint64_t nonce, sycl::uint2 *mix_hash, sycl::nd_ite
193195
case 2:
194196
mix[p] = vectorize2(shuffle_4, shuffle_5);
195197
break;
196-
case 3:
197-
mix[p] = vectorize2(shuffle_6, shuffle_7);
198-
break;
198+
default:
199+
mix[p] = vectorize2(shuffle_6, shuffle_7);
200+
break;
199201
}
200202

201203
init0[p] = item_ct1.get_sub_group().shuffle(shuffle_0.x(), iShuffleOffset);

0 commit comments

Comments
 (0)