-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
436 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed 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 <stdint.h> | ||
#include "folly/CPortability.h" | ||
|
||
namespace facebook::velox::simd { | ||
|
||
bool FOLLY_ALWAYS_INLINE alwaysTrue(const char*, const char*) { | ||
return true; | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp1(const char* a, const char* b) { | ||
return a[0] == b[0]; | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp2(const char* a, const char* b) { | ||
const uint16_t A = *reinterpret_cast<const uint16_t*>(a); | ||
const uint16_t B = *reinterpret_cast<const uint16_t*>(b); | ||
return A == B; | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp3(const char* a, const char* b) { | ||
const uint32_t A = *reinterpret_cast<const uint32_t*>(a); | ||
const uint32_t B = *reinterpret_cast<const uint32_t*>(b); | ||
return (A & 0x00ffffff) == (B & 0x00ffffff); | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp4(const char* a, const char* b) { | ||
const uint32_t A = *reinterpret_cast<const uint32_t*>(a); | ||
const uint32_t B = *reinterpret_cast<const uint32_t*>(b); | ||
return A == B; | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp5(const char* a, const char* b) { | ||
const uint64_t A = *reinterpret_cast<const uint64_t*>(a); | ||
const uint64_t B = *reinterpret_cast<const uint64_t*>(b); | ||
return ((A ^ B) & 0x000000fffffffffflu) == 0; | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp6(const char* a, const char* b) { | ||
const uint64_t A = *reinterpret_cast<const uint64_t*>(a); | ||
const uint64_t B = *reinterpret_cast<const uint64_t*>(b); | ||
return ((A ^ B) & 0x0000fffffffffffflu) == 0; | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp7(const char* a, const char* b) { | ||
const uint64_t A = *reinterpret_cast<const uint64_t*>(a); | ||
const uint64_t B = *reinterpret_cast<const uint64_t*>(b); | ||
return ((A ^ B) & 0x00fffffffffffffflu) == 0; | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp8(const char* a, const char* b) { | ||
const uint64_t A = *reinterpret_cast<const uint64_t*>(a); | ||
const uint64_t B = *reinterpret_cast<const uint64_t*>(b); | ||
return A == B; | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp9(const char* a, const char* b) { | ||
const uint64_t A = *reinterpret_cast<const uint64_t*>(a); | ||
const uint64_t B = *reinterpret_cast<const uint64_t*>(b); | ||
return (A == B) & (a[8] == b[8]); | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp10(const char* a, const char* b) { | ||
const uint64_t Aq = *reinterpret_cast<const uint64_t*>(a); | ||
const uint64_t Bq = *reinterpret_cast<const uint64_t*>(b); | ||
const uint16_t Aw = *reinterpret_cast<const uint16_t*>(a + 8); | ||
const uint16_t Bw = *reinterpret_cast<const uint16_t*>(b + 8); | ||
return (Aq == Bq) & (Aw == Bw); | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp11(const char* a, const char* b) { | ||
const uint64_t Aq = *reinterpret_cast<const uint64_t*>(a); | ||
const uint64_t Bq = *reinterpret_cast<const uint64_t*>(b); | ||
const uint32_t Ad = *reinterpret_cast<const uint32_t*>(a + 8); | ||
const uint32_t Bd = *reinterpret_cast<const uint32_t*>(b + 8); | ||
return (Aq == Bq) & ((Ad & 0x00ffffff) == (Bd & 0x00ffffff)); | ||
} | ||
|
||
bool FOLLY_ALWAYS_INLINE memcmp12(const char* a, const char* b) { | ||
const uint64_t Aq = *reinterpret_cast<const uint64_t*>(a); | ||
const uint64_t Bq = *reinterpret_cast<const uint64_t*>(b); | ||
const uint32_t Ad = *reinterpret_cast<const uint32_t*>(a + 8); | ||
const uint32_t Bd = *reinterpret_cast<const uint32_t*>(b + 8); | ||
return (Aq == Bq) & (Ad == Bd); | ||
} | ||
|
||
} // namespace facebook::velox::simd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.