Mryange commented on code in PR #38755:
URL: https://github.com/apache/doris/pull/38755#discussion_r1704826858
##########
be/src/vec/runtime/ip_address_cidr.h:
##########
@@ -73,6 +73,29 @@ bool match_ipv4_subnet(uint32_t addr, uint32_t cidr_addr,
uint8_t prefix) {
return (addr & mask) == (cidr_addr & mask);
}
+#if defined(__SSE2__) || defined(__aarch64__)
+
+bool match_ipv6_subnet(const uint8_t* addr, const uint8_t* cidr_addr, uint8_t
prefix) {
+ uint16_t mask = _mm_movemask_epi8(
+ _mm_cmpeq_epi8(_mm_loadu_si128(reinterpret_cast<const
__m128i*>(addr)),
+ _mm_loadu_si128(reinterpret_cast<const
__m128i*>(cidr_addr))));
+ mask = ~mask;
+
+ if (mask) {
+ const auto offset = std::countl_zero(mask);
+ if (prefix / 8 != offset) {
+ return prefix / 8 < offset;
+ }
+ auto cmpmask = ~(0xff >> (prefix % 8));
+ return (addr[IPV6_BINARY_LENGTH - 1 - offset] & cmpmask) ==
+ (cidr_addr[IPV6_BINARY_LENGTH - 1 - offset] & cmpmask);
+ } else {
+ // All the bytes are equal.
Review Comment:
Just for the comment
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]