Skip to content

Commit 651d82c

Browse files
committed
fix introduced test failures
1 parent 0d62954 commit 651d82c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/codegen/lowering.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,12 +517,20 @@ end
517517

518518
@generated function of_same_size(::Type{T}, ::Type{S}, ::StaticInt{R}) where {T,S,R}
519519
sizeof_S = sizeof(S)
520-
if T <: Integer && sizeof(T) == 8
521-
# sizeof(T) == 8 && max(..., 4) to maybe demote Int64 -> Int32
520+
sizeof_T = sizeof(T)
521+
if T <: Integer
522+
# max(..., 4) to maybe demote Int64 -> Int32
522523
# but otherwise, we're giving up too much with the demotion.
523-
sizeof_S *= max(8 ÷ R, 4)
524+
if T === Bool || sizeof_S < 8
525+
# HACK: T === Bool, makes code work.
526+
sizeof_S *= 8
527+
else
528+
sizeof_S *= max(8 ÷ R, 4)
529+
end
530+
# multiply by 8 for sake of following `==` comparison
531+
sizeof_T *= 8
524532
end
525-
sizeof(T) == sizeof_S && return T
533+
sizeof_T == sizeof_S && return T
526534
# Tfloat = T <: Union{Float32,Float64}
527535
if T <: Union{Float32,Float64}
528536
sizeof_S 8 ? Float64 : Float32

0 commit comments

Comments
 (0)