10ba22f51SPetr Hosek //===-- paritysi2.c - Implement __paritysi2 -------------------------------===// 20ba22f51SPetr Hosek // 30ba22f51SPetr Hosek // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40ba22f51SPetr Hosek // See https://llvm.org/LICENSE.txt for license information. 50ba22f51SPetr Hosek // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60ba22f51SPetr Hosek // 70ba22f51SPetr Hosek //===----------------------------------------------------------------------===// 80ba22f51SPetr Hosek // 90ba22f51SPetr Hosek // This file implements __paritysi2 for the compiler_rt library. 100ba22f51SPetr Hosek // 110ba22f51SPetr Hosek //===----------------------------------------------------------------------===// 12a6b264b5SAlexey Samsonov 13a6b264b5SAlexey Samsonov #include "int_lib.h" 14a6b264b5SAlexey Samsonov 150ba22f51SPetr Hosek // Returns: 1 if number of bits is odd else returns 0 16a6b264b5SAlexey Samsonov __paritysi2(si_int a)17*0ee439b7SAnatoly TrosinenkoCOMPILER_RT_ABI int __paritysi2(si_int a) { 18a6b264b5SAlexey Samsonov su_int x = (su_int)a; 19a6b264b5SAlexey Samsonov x ^= x >> 16; 20a6b264b5SAlexey Samsonov x ^= x >> 8; 21a6b264b5SAlexey Samsonov x ^= x >> 4; 22a6b264b5SAlexey Samsonov return (0x6996 >> (x & 0xF)) & 1; 23a6b264b5SAlexey Samsonov } 24