| // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir %s | %FileCheck %s |
| |
| // Test if llvm can generate code for it |
| // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -c %s |
| |
| sil_stage canonical |
| |
| import Builtin |
| |
| // CHECK-LABEL: define{{( protected)?}} swiftcc float @test_large(i2048* noalias nocapture dereferenceable(256) |
| // CHECK: %1 = load i2048, i2048* %0, align 256 |
| // CHECK: %2 = trunc i2048 %1 to i64 |
| // CHECK: %3 = sitofp i64 %2 to float |
| // CHECK: ret float %3 |
| sil @test_large : $@convention(thin) (Builtin.Int2048) -> Builtin.FPIEEE32 { |
| bb0(%0 : $Builtin.Int2048): |
| %2 = builtin "itofp_with_overflow_Int2048_FPIEEE32"(%0 : $Builtin.Int2048) : $Builtin.FPIEEE32 |
| return %2 : $Builtin.FPIEEE32 |
| } |
| |
| // CHECK-LABEL: define{{( protected)?}} swiftcc float @test_small |
| // CHECK: %1 = sext i32 %0 to i64 |
| // CHECK: %2 = sitofp i64 %1 to float |
| // CHECK: ret float %2 |
| sil @test_small : $@convention(thin) (Builtin.Int32) -> Builtin.FPIEEE32 { |
| bb0(%0 : $Builtin.Int32): |
| %2 = builtin "itofp_with_overflow_Int32_FPIEEE32"(%0 : $Builtin.Int32) : $Builtin.FPIEEE32 |
| return %2 : $Builtin.FPIEEE32 |
| } |
| |
| |