xref: /llvm-project/llvm/test/Transforms/Attributor/nofpclass-uses-to-defs.ll (revision d48d108bc66adb31185ee023e1eb0ccdda2065c1)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-annotate-decl-cs  -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
4
5declare float @llvm.arithmetic.fence.f32(float)
6declare float @extern(float)
7
8; arg missing nofpclass
9define nofpclass(nan) float @return_implies_arg(float %arg) {
10; CHECK-LABEL: define nofpclass(nan) float @return_implies_arg
11; CHECK-SAME: (float returned [[ARG:%.*]]) #[[ATTR1:[0-9]+]] {
12; CHECK-NEXT:    ret float [[ARG]]
13;
14  ret float %arg
15}
16
17; return should get marked nofpclass(inf nan)
18define internal float @callsite_implies_return() {
19; CHECK-LABEL: define internal float @callsite_implies_return() {
20; CHECK-NEXT:    [[VALUE:%.*]] = call float @extern(float noundef nofpclass(nan inf zero sub nnorm) 1.000000e+00)
21; CHECK-NEXT:    ret float [[VALUE]]
22;
23  %value = call float @extern(float 1.0)
24  ret float %value
25}
26
27; arg should get nofpclass(inf nan)
28define float @nofpclass_callsite_arg_implies_arg(float %arg) {
29; CHECK-LABEL: define float @nofpclass_callsite_arg_implies_arg
30; CHECK-SAME: (float nofpclass(nan inf) [[ARG:%.*]]) {
31; CHECK-NEXT:    [[CALL:%.*]] = call float @extern(float nofpclass(nan inf) [[ARG]])
32; CHECK-NEXT:    ret float [[CALL]]
33;
34  %call = call float @extern(float nofpclass(inf nan) %arg)
35  ret float %call
36}
37
38define float @nofpclass_earlier_call_implies_later_call_arg(float %arg) {
39; CHECK-LABEL: define float @nofpclass_earlier_call_implies_later_call_arg
40; CHECK-SAME: (float nofpclass(nan inf) [[ARG:%.*]]) {
41; CHECK-NEXT:    [[CALL0:%.*]] = call float @extern(float nofpclass(nan inf) [[ARG]])
42; CHECK-NEXT:    [[CALL1:%.*]] = call float @extern(float nofpclass(nan inf) [[ARG]])
43; CHECK-NEXT:    [[ADD:%.*]] = fadd float [[CALL0]], [[CALL1]]
44; CHECK-NEXT:    ret float [[ADD]]
45;
46  %call0 = call float @extern(float nofpclass(inf nan) %arg)
47  %call1 = call float @extern(float %arg) ; nofpclass should be implied here
48  %add = fadd float %call0, %call1
49  ret float %add
50}
51
52define float @nnan_ninf_implies_arg_return(float %arg) {
53; CHECK-LABEL: define nofpclass(nan inf) float @nnan_ninf_implies_arg_return
54; CHECK-SAME: (float [[ARG:%.*]]) {
55; CHECK-NEXT:    [[CALL:%.*]] = call nnan ninf nofpclass(nan inf) float @extern(float [[ARG]])
56; CHECK-NEXT:    ret float [[CALL]]
57;
58  %call = call nnan ninf float @extern(float %arg)
59  ret float %call
60}
61
62define float @callsite_returns_nofpclass_nan() {
63; CHECK-LABEL: define nofpclass(nan inf) float @callsite_returns_nofpclass_nan() {
64; CHECK-NEXT:    [[CALL:%.*]] = call nofpclass(nan inf) float @callsite_implies_return()
65; CHECK-NEXT:    ret float [[CALL]]
66;
67  %call = call nofpclass(inf nan) float @callsite_implies_return()
68  ret float %call
69}
70
71
72define float @nnan_implies_arg_return(float %arg) {
73; CHECK-LABEL: define nofpclass(nan) float @nnan_implies_arg_return
74; CHECK-SAME: (float [[ARG:%.*]]) {
75; CHECK-NEXT:    [[CALL:%.*]] = call nnan nofpclass(nan) float @extern(float [[ARG]])
76; CHECK-NEXT:    ret float [[CALL]]
77;
78  %call = call nnan float @extern(float %arg)
79  ret float %call
80}
81
82define float @ninf_implies_arg_return(float %arg) {
83; CHECK-LABEL: define nofpclass(inf) float @ninf_implies_arg_return
84; CHECK-SAME: (float [[ARG:%.*]]) {
85; CHECK-NEXT:    [[CALL:%.*]] = call ninf nofpclass(inf) float @extern(float [[ARG]])
86; CHECK-NEXT:    ret float [[CALL]]
87;
88  %call = call ninf float @extern(float %arg)
89  ret float %call
90}
91
92;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
93; CGSCC: {{.*}}
94; TUNIT: {{.*}}
95