You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/06/19 10:27:12 UTC
[GitHub] [arrow] pitrou commented on a diff in pull request #13393: ARROW-16849: [C++][compute] Replace If-Else branch with bitwise operators in aggregate_basic_internal
pitrou commented on code in PR #13393:
URL: https://github.com/apache/arrow/pull/13393#discussion_r901082796
##########
cpp/src/arrow/compute/kernels/aggregate_basic_internal.h:
##########
@@ -186,11 +186,8 @@ struct MeanImpl : public SumImpl<ArrowType, SimdLevel> {
// Round the decimal result based on the remainder
remainder.Abs();
if (remainder * 2 >= this->count) {
- if (this->sum >= 0) {
- quotient += 1;
- } else {
- quotient -= 1;
- }
+ auto flag = this->sum >= 0;
+ quotient = quotient + (1 & flag) - (1 & (!flag));
Review Comment:
I'm not surprised, this kind of micro-optimization where you try to second-guess actual CPU instructions and their performance using C code can often be an anti-pattern.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org