Thanks for using Compiler Explorer
Sponsors
Jakt
C++
Ada
Analysis
Assembly
C
Carbon
C++ (Circle)
CIRCT
Clean
CMake
C++ for OpenCL
MLIR
Cppx
Cppx-Blue
Cppx-Gold
Crystal
C#
CUDA C++
D
Dart
Erlang
Fortran
F#
Go
Haskell
HLSL
ispc
Java
Kotlin
LLVM IR
Nim
OCaml
OpenCL C
Pascal
Pony
Python
Ruby
Rust
Scala
Solidity
Swift
Toit
TypeScript Native
Visual Basic
Zig
swift source #1
Output
Compile to binary
Execute the code
Intel asm syntax
Demangle identifiers
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Compiler
x86-64 swiftc 3.1.1
x86-64 swiftc 4.0.2
x86-64 swiftc 4.0.3
x86-64 swiftc 4.1
x86-64 swiftc 4.1.1
x86-64 swiftc 4.1.2
x86-64 swiftc 4.2
x86-64 swiftc 5.0
x86-64 swiftc 5.1
x86-64 swiftc 5.2
x86-64 swiftc 5.3
x86-64 swiftc 5.4
x86-64 swiftc 5.5
x86-64 swiftc 5.6
x86-64 swiftc 5.7 (nightly)
x86-64 swiftc nightly
Options
Source code
func find(_ key:UInt8, in vector:SIMD16<UInt8>, _ body:(Int) -> ()) { // (key: 5, vector: (1, 5, 1, 1, 5, 5, 1, 1, 1, 1, 1, 1, 5, 1, 1, 5)) let places:SIMD16<UInt8> = .init(128, 64, 32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1), match:SIMD16<UInt8> = places.replacing(with: 0, where: vector .!= key) // match: ( 0, 64, 0, 0, 8, 4, 0, 0, 0, 0, 0, 0, 8, 0, 0, 1) let r8:SIMD8<UInt8> = match.evenHalf | match.oddHalf, r4:SIMD4<UInt8> = r8.evenHalf | r8.oddHalf, r2:SIMD2<UInt8> = r4.evenHalf | r4.oddHalf let r:UInt16 = .init(r2.x) << 8 | .init(r2.y) // r: 0b0100_1100_0000_1001 var i:Int = r.leadingZeroBitCount while i < 16 { try body(i) i += 1 + ((r << i) << 1).leadingZeroBitCount } }
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
About the author
Changelog
Version tree