1 ; Test some floating point casting cases 2 ; RUN: opt < %s -instcombine -S | FileCheck %s 3 4 define i8 @test1() { 5 %x = fptoui float 2.550000e+02 to i8 ; <i8> [#uses=1] 6 ret i8 %x 7 ; CHECK: ret i8 -1 8 } 9 10 define i8 @test2() { 11 %x = fptosi float -1.000000e+00 to i8 ; <i8> [#uses=1] 12 ret i8 %x 13 ; CHECK: ret i8 -1 14 } 15 16 ; CHECK: test3 17 define half @test3(float %a) { 18 ; CHECK: fptrunc 19 ; CHECK: llvm.fabs.f16 20 %b = call float @llvm.fabs.f32(float %a) 21 %c = fptrunc float %b to half 22 ret half %c 23 } 24 25 ; CHECK: test4 26 define half @test4(float %a) { 27 ; CHECK: fptrunc 28 ; CHECK: fsub 29 %b = fsub float -0.0, %a 30 %c = fptrunc float %b to half 31 ret half %c 32 } 33 34 declare float @llvm.fabs.f32(float) nounwind readonly 35