From: Matt Arsenault Date: Mon, 1 Apr 2019 14:03:44 +0000 (+0000) Subject: InstSimplify: Add baseline test for upcoming change X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b52beb74975c934ba8eabe889ff494dab75090f9;p=llvm InstSimplify: Add baseline test for upcoming change git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357386 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstSimplify/round-intrinsics.ll b/test/Transforms/InstSimplify/round-intrinsics.ll new file mode 100644 index 00000000000..ff7015b2f7e --- /dev/null +++ b/test/Transforms/InstSimplify/round-intrinsics.ll @@ -0,0 +1,120 @@ +; 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: [[ROUND:%.*]] = call float @llvm.floor.f32(float [[CVT]]) +; CHECK-NEXT: ret float [[ROUND]] +; + %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: [[ROUND:%.*]] = call float @llvm.floor.f32(float [[CVT]]) +; CHECK-NEXT: ret float [[ROUND]] +; + %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: [[ROUND:%.*]] = call float @llvm.trunc.f32(float [[CVT]]) +; CHECK-NEXT: ret float [[ROUND]] +; + %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: [[ROUND:%.*]] = call float @llvm.trunc.f32(float [[CVT]]) +; CHECK-NEXT: ret float [[ROUND]] +; + %cvt = uitofp i32 %arg to float + %round = call float @llvm.trunc.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: [[ROUND:%.*]] = call float @llvm.round.f32(float [[CVT]]) +; CHECK-NEXT: ret float [[ROUND]] +; + %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: [[ROUND:%.*]] = call float @llvm.round.f32(float [[CVT]]) +; CHECK-NEXT: ret float [[ROUND]] +; + %cvt = uitofp i32 %arg to float + %round = call float @llvm.round.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: [[NEARBYINT:%.*]] = call float @llvm.nearbyint.f32(float [[CVT]]) +; CHECK-NEXT: ret float [[NEARBYINT]] +; + %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: [[NEARBYINT:%.*]] = call float @llvm.nearbyint.f32(float [[CVT]]) +; CHECK-NEXT: ret float [[NEARBYINT]] +; + %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: [[RINT:%.*]] = call float @llvm.rint.f32(float [[CVT]]) +; CHECK-NEXT: ret float [[RINT]] +; + %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: [[RINT:%.*]] = call float @llvm.rint.f32(float [[CVT]]) +; CHECK-NEXT: ret float [[RINT]] +; + %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.round.f32(float) #0 +declare float @llvm.nearbyint.f32(float) #0 +declare float @llvm.rint.f32(float) #0 + +attributes #0 = { nounwind readnone speculatable }