Skip to content

Commit fd1a735

Browse files
authored
Merge pull request #18149 from JuliaLang/jb/fasterbitshift
replace branch in bit shift operators, helps #18135
2 parents e3173d3 + e02692f commit fd1a735

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

base/int.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ trailing_ones(x::Integer) = trailing_zeros(~x)
182182
# note: this early during bootstrap, `>=` is not yet available
183183
# note: we only define Int shift counts here; the generic case is handled later
184184
>>(x::BitInteger, y::Int) =
185-
0 <= y ? x >> unsigned(y) : x << unsigned(-y)
185+
select_value(0 <= y, x >> unsigned(y), x << unsigned(-y))
186186
<<(x::BitInteger, y::Int) =
187-
0 <= y ? x << unsigned(y) : x >> unsigned(-y)
187+
select_value(0 <= y, x << unsigned(y), x >> unsigned(-y))
188188
>>>(x::BitInteger, y::Int) =
189-
0 <= y ? x >>> unsigned(y) : x << unsigned(-y)
189+
select_value(0 <= y, x >>> unsigned(y), x << unsigned(-y))
190190

191191
## integer conversions ##
192192

0 commit comments

Comments
 (0)