pitrou commented on code in PR #37792: URL: https://github.com/apache/arrow/pull/37792#discussion_r1352800783
########## cpp/src/arrow/util/assume_aligned.h: ########## @@ -0,0 +1,45 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include <cstddef> + +namespace arrow::util { + +template <size_t N, typename P> +[[nodiscard]] constexpr P* AssumeAligned(P* ptr) { +#if defined(__has_builtin) +#if __has_builtin(__builtin_assume_aligned) +#define ARROW_HAS_BUILTIN_ASSUME_ALIGNED +#endif +#endif + +#if defined(ARROW_HAS_BUILTIN_ASSUME_ALIGNED) +#undef ARROW_HAS_BUILTIN_ASSUME_ALIGNED + return static_cast<P*>(__builtin_assume_aligned(ptr, N)); Review Comment: > For example, observe that inline_equal_unaligned https://godbolt.org/z/cvfo9vErY has preamble then calls into inline_equal. Well, if you move one function over the other, you'll see that the preambles are just moved around. IOW, gcc is just trying to minimize code size here. Switch to a newer GCC version, then both `inline_equal` and `inline_equal_unaligned` produce exactly the same code. Also sidenote, this is testing for ARM32... Switch to ARM64 and the code is much shorter _and_ identical for all three functions. -- 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]
