| // RUN: %target-swift-frontend -emit-ir %s | FileCheck %s |
| |
| // Test if llvm can generate code for it |
| // RUN: %target-swift-frontend -c %s |
| |
| sil_stage canonical |
| |
| import Builtin |
| |
| // CHECK-LABEL: define{{( protected)?}} float @test_large |
| // CHECK: %1 = trunc i2048 %0 to i64 |
| // CHECK: %2 = sitofp i64 %1 to float |
| // CHECK: ret float %2 |
| 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)?}} 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 |
| } |
| |
| |