From c0022d333a7d3781db47427f1ce871d8affc5317 Mon Sep 17 00:00:00 2001 From: Serdar Dogruyol Date: Thu, 4 Jan 2018 13:58:47 +0300 Subject: [PATCH] Use Intrinsics.popcount128 --- src/int.cr | 10 ++-------- src/intrinsics.cr | 4 +--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/int.cr b/src/int.cr index b0684402463a..00454ab97774 100644 --- a/src/int.cr +++ b/src/int.cr @@ -681,10 +681,7 @@ struct Int128 end def popcount - # TODO: use after Crystal 0.23.1 - # Intrinsics.popcount128(self) - v1, v2 = self.unsafe_as({Int64, Int64}) - Int128.new(v1.popcount + v2.popcount) + Intrinsics.popcount128(self) end def clone @@ -795,10 +792,7 @@ struct UInt128 end def popcount - # TODO: use after Crystal 0.23.1 - # Intrinsics.popcount128(self) - v1, v2 = self.unsafe_as({UInt64, UInt64}) - UInt128.new(v1.popcount + v2.popcount) + Intrinsics.popcount128(self) end def clone diff --git a/src/intrinsics.cr b/src/intrinsics.cr index a4ee8fb71ed6..edf4f14548cb 100644 --- a/src/intrinsics.cr +++ b/src/intrinsics.cr @@ -16,9 +16,7 @@ lib Intrinsics fun popcount16 = "llvm.ctpop.i16"(src : Int16) : Int16 fun popcount32 = "llvm.ctpop.i32"(src : Int32) : Int32 fun popcount64 = "llvm.ctpop.i64"(src : Int64) : Int64 - - # TODO: uncomment and use in int.cr after Crystal 0.23.1 - # fun popcount128 = "llvm.ctpop.i128"(src : Int128) : Int128 + fun popcount128 = "llvm.ctpop.i128"(src : Int128) : Int128 fun va_start = "llvm.va_start"(ap : Void*) fun va_end = "llvm.va_end"(ap : Void*)