From f3c299fc52b9d107c6e29ec38b18626f5223a391 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sun, 9 Apr 2023 06:49:48 -0400 Subject: [PATCH] ValueTracking: Add baseline test for trunc computeKnownFPClass handling --- llvm/test/Transforms/Attributor/nofpclass-trunc.ll | 167 +++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 llvm/test/Transforms/Attributor/nofpclass-trunc.ll diff --git a/llvm/test/Transforms/Attributor/nofpclass-trunc.ll b/llvm/test/Transforms/Attributor/nofpclass-trunc.ll new file mode 100644 index 0000000..37f128a --- /dev/null +++ b/llvm/test/Transforms/Attributor/nofpclass-trunc.ll @@ -0,0 +1,167 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2 +; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT + +declare float @llvm.trunc.f32(float) +declare ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128) + +define float @ret_trunc(float %arg0) { +; CHECK-LABEL: define float @ret_trunc +; CHECK-SAME: (float [[ARG0:%.*]]) #[[ATTR1:[0-9]+]] { +; CHECK-NEXT: [[CALL:%.*]] = call float @llvm.trunc.f32(float [[ARG0]]) #[[ATTR2:[0-9]+]] +; CHECK-NEXT: ret float [[CALL]] +; + %call = call float @llvm.trunc.f32(float %arg0) + ret float %call +} + +define float @ret_trunc_noinf(float nofpclass(inf) %arg0) { +; CHECK-LABEL: define float @ret_trunc_noinf +; CHECK-SAME: (float nofpclass(inf) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call float @llvm.trunc.f32(float [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret float [[CALL]] +; + %call = call float @llvm.trunc.f32(float %arg0) + ret float %call +} + +define float @ret_trunc_nopinf(float nofpclass(pinf) %arg0) { +; CHECK-LABEL: define float @ret_trunc_nopinf +; CHECK-SAME: (float nofpclass(pinf) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call float @llvm.trunc.f32(float [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret float [[CALL]] +; + %call = call float @llvm.trunc.f32(float %arg0) + ret float %call +} + +define float @ret_trunc_noninf(float nofpclass(ninf) %arg0) { +; CHECK-LABEL: define float @ret_trunc_noninf +; CHECK-SAME: (float nofpclass(ninf) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call float @llvm.trunc.f32(float [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret float [[CALL]] +; + %call = call float @llvm.trunc.f32(float %arg0) + ret float %call +} + +define float @ret_trunc_nonan(float nofpclass(nan) %arg0) { +; CHECK-LABEL: define float @ret_trunc_nonan +; CHECK-SAME: (float nofpclass(nan) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call float @llvm.trunc.f32(float [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret float [[CALL]] +; + %call = call float @llvm.trunc.f32(float %arg0) + ret float %call +} + +define float @ret_trunc_noqnan(float nofpclass(qnan) %arg0) { +; CHECK-LABEL: define float @ret_trunc_noqnan +; CHECK-SAME: (float nofpclass(qnan) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call float @llvm.trunc.f32(float [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret float [[CALL]] +; + %call = call float @llvm.trunc.f32(float %arg0) + ret float %call +} + +define float @ret_trunc_nosnan(float nofpclass(snan) %arg0) { +; CHECK-LABEL: define float @ret_trunc_nosnan +; CHECK-SAME: (float nofpclass(snan) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call float @llvm.trunc.f32(float [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret float [[CALL]] +; + %call = call float @llvm.trunc.f32(float %arg0) + ret float %call +} + +define float @ret_trunc_nozero(float nofpclass(zero) %arg0) { +; CHECK-LABEL: define float @ret_trunc_nozero +; CHECK-SAME: (float nofpclass(zero) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call float @llvm.trunc.f32(float [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret float [[CALL]] +; + %call = call float @llvm.trunc.f32(float %arg0) + ret float %call +} + +define float @ret_trunc_nopzero(float nofpclass(pzero) %arg0) { +; CHECK-LABEL: define float @ret_trunc_nopzero +; CHECK-SAME: (float nofpclass(pzero) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call float @llvm.trunc.f32(float [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret float [[CALL]] +; + %call = call float @llvm.trunc.f32(float %arg0) + ret float %call +} + +define float @ret_trunc_nonzero(float nofpclass(nzero) %arg0) { +; CHECK-LABEL: define float @ret_trunc_nonzero +; CHECK-SAME: (float nofpclass(nzero) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call float @llvm.trunc.f32(float [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret float [[CALL]] +; + %call = call float @llvm.trunc.f32(float %arg0) + ret float %call +} + +define float @ret_trunc_nonorm(float nofpclass(norm) %arg0) { +; CHECK-LABEL: define float @ret_trunc_nonorm +; CHECK-SAME: (float nofpclass(norm) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call float @llvm.trunc.f32(float [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret float [[CALL]] +; + %call = call float @llvm.trunc.f32(float %arg0) + ret float %call +} + +define ppc_fp128 @ret_trunc_ppcf128(ppc_fp128 %arg0) { +; CHECK-LABEL: define ppc_fp128 @ret_trunc_ppcf128 +; CHECK-SAME: (ppc_fp128 [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret ppc_fp128 [[CALL]] +; + %call = call ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 %arg0) + ret ppc_fp128 %call +} + +define ppc_fp128 @ret_trunc_noinf_ppcf128(ppc_fp128 nofpclass(inf) %arg0) { +; CHECK-LABEL: define ppc_fp128 @ret_trunc_noinf_ppcf128 +; CHECK-SAME: (ppc_fp128 nofpclass(inf) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret ppc_fp128 [[CALL]] +; + %call = call ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 %arg0) + ret ppc_fp128 %call +} + +define ppc_fp128 @ret_trunc_nopinf_ppcf128(ppc_fp128 nofpclass(pinf) %arg0) { +; CHECK-LABEL: define ppc_fp128 @ret_trunc_nopinf_ppcf128 +; CHECK-SAME: (ppc_fp128 nofpclass(pinf) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret ppc_fp128 [[CALL]] +; + %call = call ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 %arg0) + ret ppc_fp128 %call +} + +define ppc_fp128 @ret_trunc_noninf_ppcf128(ppc_fp128 nofpclass(ninf) %arg0) { +; CHECK-LABEL: define ppc_fp128 @ret_trunc_noninf_ppcf128 +; CHECK-SAME: (ppc_fp128 nofpclass(ninf) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret ppc_fp128 [[CALL]] +; + %call = call ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 %arg0) + ret ppc_fp128 %call +} + +define ppc_fp128 @ret_trunc_nonan_ppcf128(ppc_fp128 nofpclass(nan) %arg0) { +; CHECK-LABEL: define ppc_fp128 @ret_trunc_nonan_ppcf128 +; CHECK-SAME: (ppc_fp128 nofpclass(nan) [[ARG0:%.*]]) #[[ATTR1]] { +; CHECK-NEXT: [[CALL:%.*]] = call ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 [[ARG0]]) #[[ATTR2]] +; CHECK-NEXT: ret ppc_fp128 [[CALL]] +; + %call = call ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128 %arg0) + ret ppc_fp128 %call +} +;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: +; TUNIT: {{.*}} -- 2.7.4