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/11/09 16:38:14 UTC

[GitHub] [arrow] zeroshade commented on a diff in pull request #14605: ARROW-18109: [Go] Initial Unary Arithmetic

zeroshade commented on code in PR #14605:
URL: https://github.com/apache/arrow/pull/14605#discussion_r1018172127


##########
go/arrow/compute/internal/kernels/_lib/base_arithmetic.cc:
##########
@@ -125,6 +133,69 @@ struct MultiplyChecked {
     }
 };
 
+struct AbsoluteValue {
+    template <typename T, typename Arg>
+    static constexpr T Call(Arg input) {
+        if constexpr(is_same_v<Arg, float>) {
+            *(((int*)&input)+0) &= 0x7fffffff;
+            return input;
+        } else if constexpr(is_same_v<Arg, double>) {
+            *(((int*)&input)+1) &= 0x7fffffff;

Review Comment:
   Also, I'm using clang, not gcc and it looks like clang recognizes it and optimizes correctly: https://godbolt.org/z/v1Eha8r41
   
   I spot the same `addps` in the output for the x86-64 assembly only it's vectorized so it's `vaddps`



-- 
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