//===--- SIMDFloatComparisons.swift.gyb -----------------------*- swift -*-===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2025 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// // RUN: %empty-directory(%t) // RUN: %gyb %s -o %t/SIMDFloatComparisons.swift // RUN: %target-swift-frontend -primary-file %t/SIMDFloatComparisons.swift -emit-ir | %FileCheck %t/SIMDFloatComparisons.swift --check-prefix=CHECK --check-prefix=CHECK-%target-cpu import Swift %for bits in [16,32,64]: % scalar = {16:'Float16',32:'Float',64:'Double'}[bits] % llvm = {16:'half',32:'float',64:'double'}[bits] % for totalBits in [64,128]: % if bits == 16 or totalBits == 64: % arch = "-arm64" % else: % arch = "" % end % n = totalBits // bits % if n != 1: % neonSuffix = str(n) + {8:'b',16:'h',32:'s',64:'d'}[bits] % if bits == 16: #if arch(arm64) @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) % end func compare_eq${n}x${bits}( _ a: SIMD${n}<${scalar}>, _ b: SIMD${n}<${scalar}> ) -> SIMDMask> { a .== b } % if bits == 16: #endif % end // CHECK${arch}: compare_eq${n}x${bits}{{.*}} { // CHECK${arch}: entry: // CHECK${arch}: [[TMP:%[0-9]+]] = fcmp oeq <${n} x ${llvm}> %0, %1 // CHECK${arch}-NEXT: sext <${n} x i1> [[TMP]] to <${n} x i${bits}> % if bits == 16: #if arch(arm64) @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) % end func compare_ne${n}x${bits}( _ a: SIMD${n}<${scalar}>, _ b: SIMD${n}<${scalar}> ) -> SIMDMask> { a .!= b } % if bits == 16: #endif % end // CHECK${arch}: compare_ne${n}x${bits}{{.*}} { // CHECK${arch}: entry: // CHECK${arch}: [[TMP:%[0-9]+]] = fcmp une <${n} x ${llvm}> %0, %1 // CHECK${arch}-NEXT: sext <${n} x i1> [[TMP]] to <${n} x i${bits}> % if bits == 16: #if arch(arm64) @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) % end func compare_lt${n}x${bits}( _ a: SIMD${n}<${scalar}>, _ b: SIMD${n}<${scalar}> ) -> SIMDMask> { a .< b } % if bits == 16: #endif % end // CHECK${arch}: compare_lt${n}x${bits}{{.*}} { // CHECK${arch}: entry: // CHECK${arch}: [[TMP:%[0-9]+]] = fcmp olt <${n} x ${llvm}> %0, %1 // CHECK${arch}-NEXT: sext <${n} x i1> [[TMP]] to <${n} x i${bits}> % if bits == 16: #if arch(arm64) @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) % end func compare_le${n}x${bits}( _ a: SIMD${n}<${scalar}>, _ b: SIMD${n}<${scalar}> ) -> SIMDMask> { a .<= b } % if bits == 16: #endif % end // CHECK${arch}: compare_le${n}x${bits}{{.*}} { // CHECK${arch}: entry: // CHECK${arch}: [[TMP:%[0-9]+]] = fcmp ole <${n} x ${llvm}> %0, %1 // CHECK${arch}-NEXT: sext <${n} x i1> [[TMP]] to <${n} x i${bits}> % if bits == 16: #if arch(arm64) @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) % end func compare_ge${n}x${bits}( _ a: SIMD${n}<${scalar}>, _ b: SIMD${n}<${scalar}> ) -> SIMDMask> { a .>= b } % if bits == 16: #endif % end // CHECK${arch}: compare_ge${n}x${bits}{{.*}} { // CHECK${arch}: entry: // CHECK${arch}: [[TMP:%[0-9]+]] = fcmp oge <${n} x ${llvm}> %0, %1 // CHECK${arch}-NEXT: sext <${n} x i1> [[TMP]] to <${n} x i${bits}> % if bits == 16: #if arch(arm64) @available(macOS 11.0, iOS 14.0, tvOS 14.0, watchOS 7.0, *) % end func compare_gt${n}x${bits}( _ a: SIMD${n}<${scalar}>, _ b: SIMD${n}<${scalar}> ) -> SIMDMask> { a .> b } % if bits == 16: #endif % end // CHECK${arch}: compare_gt${n}x${bits}{{.*}} { // CHECK${arch}: entry: // CHECK${arch}: [[TMP:%[0-9]+]] = fcmp ogt <${n} x ${llvm}> %0, %1 // CHECK${arch}-NEXT: sext <${n} x i1> [[TMP]] to <${n} x i${bits}> % end % end %end