brintos

brintos / llvm-project-archived public Read only

0
0
Text · 808 B · 3d55b40 Raw
17 lines · plain
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// rhadd = (x+y+1)>>110// This can be simplified to x>>1 + y>>1 + (1 if either x or y have the 1s bit11// set) This saves us having to do any checks for overflow in the addition sums12_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_rhadd(__CLC_GENTYPE x,13                                                 __CLC_GENTYPE y) {14  return (x >> (__CLC_GENTYPE)1) + (y >> (__CLC_GENTYPE)1) +15         ((x & (__CLC_GENTYPE)1) | (y & (__CLC_GENTYPE)1));16}17