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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to