[compiler-rt] 35f708a - [builtins] Inline __paritysi2 into __paritydi2 and inline __paritydi2 into __parityti2.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 7 17:58:11 PDT 2020


Author: Craig Topper
Date: 2020-09-07T17:57:39-07:00
New Revision: 35f708a3c9ffceacbeaf8abfb0ba5123e346b30e

URL: https://github.com/llvm/llvm-project/commit/35f708a3c9ffceacbeaf8abfb0ba5123e346b30e
DIFF: https://github.com/llvm/llvm-project/commit/35f708a3c9ffceacbeaf8abfb0ba5123e346b30e.diff

LOG: [builtins] Inline __paritysi2 into __paritydi2 and inline __paritydi2 into __parityti2.

No point in making __parityti2 go through 2 calls to get to
__paritysi2.

Reviewed By: MaskRay, efriedma

Differential Revision: https://reviews.llvm.org/D87218

Added: 
    

Modified: 
    compiler-rt/lib/builtins/paritydi2.c
    compiler-rt/lib/builtins/parityti2.c

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/builtins/paritydi2.c b/compiler-rt/lib/builtins/paritydi2.c
index 58e85f89e043..350dceb8cef5 100644
--- a/compiler-rt/lib/builtins/paritydi2.c
+++ b/compiler-rt/lib/builtins/paritydi2.c
@@ -17,5 +17,9 @@
 COMPILER_RT_ABI int __paritydi2(di_int a) {
   dwords x;
   x.all = a;
-  return __paritysi2(x.s.high ^ x.s.low);
+  su_int x2 = x.s.high ^ x.s.low;
+  x2 ^= x2 >> 16;
+  x2 ^= x2 >> 8;
+  x2 ^= x2 >> 4;
+  return (0x6996 >> (x2 & 0xF)) & 1;
 }

diff  --git a/compiler-rt/lib/builtins/parityti2.c b/compiler-rt/lib/builtins/parityti2.c
index 79e920d8a02d..011c8dd45562 100644
--- a/compiler-rt/lib/builtins/parityti2.c
+++ b/compiler-rt/lib/builtins/parityti2.c
@@ -18,8 +18,14 @@
 
 COMPILER_RT_ABI int __parityti2(ti_int a) {
   twords x;
+  dwords x2;
   x.all = a;
-  return __paritydi2(x.s.high ^ x.s.low);
+  x2.all = x.s.high ^ x.s.low;
+  su_int x3 = x2.s.high ^ x2.s.low;
+  x3 ^= x3 >> 16;
+  x3 ^= x3 >> 8;
+  x3 ^= x3 >> 4;
+  return (0x6996 >> (x3 & 0xF)) & 1;
 }
 
 #endif // CRT_HAS_128BIT


        


More information about the llvm-commits mailing list