2006-11-27 01:05:10 +00:00
|
|
|
; Test some floating point casting cases
|
2009-10-12 07:18:14 +00:00
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
2006-11-27 01:05:10 +00:00
|
|
|
|
2008-03-09 08:16:40 +00:00
|
|
|
define i8 @test1() {
|
|
|
|
%x = fptoui float 2.550000e+02 to i8 ; <i8> [#uses=1]
|
|
|
|
ret i8 %x
|
2009-10-12 07:18:14 +00:00
|
|
|
; CHECK: ret i8 -1
|
2006-11-27 01:05:10 +00:00
|
|
|
}
|
|
|
|
|
2008-03-09 08:16:40 +00:00
|
|
|
define i8 @test2() {
|
|
|
|
%x = fptosi float -1.000000e+00 to i8 ; <i8> [#uses=1]
|
|
|
|
ret i8 %x
|
2009-10-12 07:18:14 +00:00
|
|
|
; CHECK: ret i8 -1
|
2006-11-27 01:05:10 +00:00
|
|
|
}
|
2008-03-09 08:16:40 +00:00
|
|
|
|
2013-01-10 22:06:52 +00:00
|
|
|
; CHECK: test3
|
|
|
|
define half @test3(float %a) {
|
|
|
|
; CHECK: fptrunc
|
|
|
|
; CHECK: llvm.fabs.f16
|
|
|
|
%b = call float @llvm.fabs.f32(float %a)
|
|
|
|
%c = fptrunc float %b to half
|
|
|
|
ret half %c
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: test4
|
|
|
|
define half @test4(float %a) {
|
|
|
|
; CHECK: fptrunc
|
|
|
|
; CHECK: fsub
|
|
|
|
%b = fsub float -0.0, %a
|
|
|
|
%c = fptrunc float %b to half
|
|
|
|
ret half %c
|
|
|
|
}
|
|
|
|
|
|
|
|
declare float @llvm.fabs.f32(float) nounwind readonly
|