Skip to content

Commit

Permalink
don't use llvm intrinsic at all
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Nov 15, 2024
1 parent ffb5c96 commit 77a4987
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions src/float/fast_float/bigint.cr
Original file line number Diff line number Diff line change
Expand Up @@ -201,31 +201,13 @@ module Float::FastFloat
uint64_hi64(x0, x1.unsafe_shl(32) | x2)
end

{% unless flag?(:interpreted) %}
lib Intrinsics
{% if Limb == UInt64 %}
fun uadd_with_overflow_i64 = "llvm.uadd.with.overflow.i64"(UInt64, UInt64) : {UInt64, Bool}
{% else %}
fun uadd_with_overflow_i32 = "llvm.uadd.with.overflow.i32"(UInt32, UInt32) : {UInt32, Bool}
{% end %}
end
{% end %}

# add two small integers, checking for overflow.
# we want an efficient operation.
# NOTE(crystal): returns also *overflow* by value
def self.scalar_add(x : Limb, y : Limb) : {Limb, Bool}
{% if flag?(:interpreted) %}
z = x &+ y
overflow = z < x
{z, overflow}
{% else %}
{% if Limb == UInt64 %}
Intrinsics.uadd_with_overflow_i64(x, y)
{% else %}
Intrinsics.uadd_with_overflow_i32(x, y)
{% end %}
{% end %}
z = x &+ y
overflow = z < x
{z, overflow}
end

# multiply two small integers, getting both the high and low bits.
Expand Down

0 comments on commit 77a4987

Please sign in to comment.