1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/test/Transforms/InstSimplify/round-intrinsics.ll
Serge Pavlov e9538ca02f [FPEnv] Intrinsic llvm.roundeven
This intrinsic implements IEEE-754 operation roundToIntegralTiesToEven,
and performs rounding to the nearest integer value, rounding halfway
cases to even. The intrinsic represents the missed case of IEEE-754
rounding operations and now llvm provides full support of the rounding
operations defined by the standard.

Differential Revision: https://reviews.llvm.org/D75670
2020-05-26 19:24:58 +07:00

143 lines
4.0 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instsimplify %s | FileCheck %s
define float @sitofp_floor(i32 %arg) {
; CHECK-LABEL: @sitofp_floor(
; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = sitofp i32 %arg to float
%round = call float @llvm.floor.f32(float %cvt)
ret float %round
}
define float @uitofp_floor(i32 %arg) {
; CHECK-LABEL: @uitofp_floor(
; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = uitofp i32 %arg to float
%round = call float @llvm.floor.f32(float %cvt)
ret float %round
}
define float @sitofp_trunc(i32 %arg) {
; CHECK-LABEL: @sitofp_trunc(
; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = sitofp i32 %arg to float
%round = call float @llvm.trunc.f32(float %cvt)
ret float %round
}
define float @uitofp_trunc(i32 %arg) {
; CHECK-LABEL: @uitofp_trunc(
; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = uitofp i32 %arg to float
%round = call float @llvm.trunc.f32(float %cvt)
ret float %round
}
define float @sitofp_ceil(i32 %arg) {
; CHECK-LABEL: @sitofp_ceil(
; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = sitofp i32 %arg to float
%round = call float @llvm.ceil.f32(float %cvt)
ret float %round
}
define float @uitofp_ceil(i32 %arg) {
; CHECK-LABEL: @uitofp_ceil(
; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = uitofp i32 %arg to float
%round = call float @llvm.ceil.f32(float %cvt)
ret float %round
}
define float @sitofp_round(i32 %arg) {
; CHECK-LABEL: @sitofp_round(
; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = sitofp i32 %arg to float
%round = call float @llvm.round.f32(float %cvt)
ret float %round
}
define float @uitofp_round(i32 %arg) {
; CHECK-LABEL: @uitofp_round(
; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = uitofp i32 %arg to float
%round = call float @llvm.round.f32(float %cvt)
ret float %round
}
define float @uitofp_roundeven(i32 %arg) {
; CHECK-LABEL: @uitofp_roundeven(
; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = uitofp i32 %arg to float
%round = call float @llvm.roundeven.f32(float %cvt)
ret float %round
}
define float @sitofp_nearbyint(i32 %arg) {
; CHECK-LABEL: @sitofp_nearbyint(
; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = sitofp i32 %arg to float
%nearbyint = call float @llvm.nearbyint.f32(float %cvt)
ret float %nearbyint
}
define float @uitofp_nearbyint(i32 %arg) {
; CHECK-LABEL: @uitofp_nearbyint(
; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = uitofp i32 %arg to float
%nearbyint = call float @llvm.nearbyint.f32(float %cvt)
ret float %nearbyint
}
define float @sitofp_rint(i32 %arg) {
; CHECK-LABEL: @sitofp_rint(
; CHECK-NEXT: [[CVT:%.*]] = sitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = sitofp i32 %arg to float
%rint = call float @llvm.rint.f32(float %cvt)
ret float %rint
}
define float @uitofp_rint(i32 %arg) {
; CHECK-LABEL: @uitofp_rint(
; CHECK-NEXT: [[CVT:%.*]] = uitofp i32 [[ARG:%.*]] to float
; CHECK-NEXT: ret float [[CVT]]
;
%cvt = uitofp i32 %arg to float
%rint = call float @llvm.rint.f32(float %cvt)
ret float %rint
}
declare float @llvm.floor.f32(float) #0
declare float @llvm.trunc.f32(float) #0
declare float @llvm.ceil.f32(float) #0
declare float @llvm.round.f32(float) #0
declare float @llvm.roundeven.f32(float) #0
declare float @llvm.nearbyint.f32(float) #0
declare float @llvm.rint.f32(float) #0
attributes #0 = { nounwind readnone speculatable }