Skip to content

Commit 332bd67

Browse files
committed
wip
1 parent bee7202 commit 332bd67

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

inc/zoo/swar/associative_iteration.h

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,19 @@ constexpr auto multiply(T a , T b) {
222222
}
223223
};
224224

225-
auto halver = [](auto count) {
225+
auto updateCount = [](auto count) {
226226
return count << 1;
227227
};
228228

229229
constexpr auto numBits = sizeof(T) * 8;
230-
constexpr auto msb = 1 << (numBits - 1);
231230
return associativeOperatorIterated_regressive(
232-
a, // base
233-
0, // neutral
234-
b, // count
235-
0, // forSquaring, pretty sure this is where i am not understanding
236-
operation, // operation
237-
numBits, // log2Count
238-
halver // halver
231+
a, // base
232+
0, // neutral
233+
b, // count
234+
1, // forSquaring, pretty sure this is where i am not understanding
235+
operation, // operation
236+
numBits, // log2Count
237+
updateCount // halver
239238
);
240239
}
241240

@@ -278,16 +277,9 @@ constexpr auto exponentiation_OverflowUnsafe_SpecificBitCount(
278277

279278
auto operation = [](auto left, auto right, auto counts) {
280279
const auto mask = makeLaneMaskFromMSB(counts);
281-
const auto antiMask = ~mask;
282280
const auto product =
283281
multiplication_OverflowUnsafe_SpecificBitCount<ActualBits>(left, right);
284-
/*
285-
* if (count)
286-
* return product;
287-
* else
288-
* return left;
289-
*/
290-
return (product & mask) | (left & antiMask);
282+
return (product & mask) | (left & ~mask);
291283
};
292284

293285
// halver should work same as multiplication... i think...
@@ -308,7 +300,7 @@ constexpr auto exponentiation_OverflowUnsafe_SpecificBitCount(
308300
);
309301
}
310302

311-
/// \note Not removed yet because it is an example of "progressive" associative exponentiation
303+
// \note Not removed yet because it is an example of "progressive" associative exponentiation
312304
template<int ActualBits, int NB, typename T>
313305
constexpr auto multiplication_OverflowUnsafe_SpecificBitCount_deprecated(
314306
SWAR<NB, T> multiplicand,

0 commit comments

Comments
 (0)