xref: /llvm-project/llvm/test/Transforms/Attributor/IPConstantProp/PR16052.ll (revision cd3a4c31bc9694d160de54c6a4daa53e152cb463)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
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
5target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6target triple = "x86_64-unknown-linux-gnu"
7
8define i64 @fn2() {
9;
10; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
11; TUNIT-LABEL: define {{[^@]+}}@fn2
12; TUNIT-SAME: () #[[ATTR0:[0-9]+]] {
13; TUNIT-NEXT:  entry:
14; TUNIT-NEXT:    ret i64 undef
15;
16; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
17; CGSCC-LABEL: define {{[^@]+}}@fn2
18; CGSCC-SAME: () #[[ATTR0:[0-9]+]] {
19; CGSCC-NEXT:  entry:
20; CGSCC-NEXT:    [[CONV:%.*]] = sext i32 undef to i64
21; CGSCC-NEXT:    [[DIV:%.*]] = sdiv i64 8, [[CONV]]
22; CGSCC-NEXT:    [[CALL2:%.*]] = call i64 @fn1(i64 [[DIV]]) #[[ATTR2:[0-9]+]]
23; CGSCC-NEXT:    ret i64 [[CALL2]]
24;
25entry:
26  %conv = sext i32 undef to i64
27  %div = sdiv i64 8, %conv
28  %call2 = call i64 @fn1(i64 %div)
29  ret i64 %call2
30}
31
32define i64 @fn2b(i32 %arg) {
33;
34; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
35; TUNIT-LABEL: define {{[^@]+}}@fn2b
36; TUNIT-SAME: (i32 [[ARG:%.*]]) #[[ATTR0]] {
37; TUNIT-NEXT:  entry:
38; TUNIT-NEXT:    [[CONV:%.*]] = sext i32 [[ARG]] to i64
39; TUNIT-NEXT:    [[DIV:%.*]] = sdiv i64 8, [[CONV]]
40; TUNIT-NEXT:    ret i64 [[DIV]]
41;
42; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
43; CGSCC-LABEL: define {{[^@]+}}@fn2b
44; CGSCC-SAME: (i32 [[ARG:%.*]]) #[[ATTR0]] {
45; CGSCC-NEXT:  entry:
46; CGSCC-NEXT:    [[CONV:%.*]] = sext i32 [[ARG]] to i64
47; CGSCC-NEXT:    [[DIV:%.*]] = sdiv i64 8, [[CONV]]
48; CGSCC-NEXT:    [[CALL2:%.*]] = call i64 @fn1(i64 [[DIV]]) #[[ATTR2]]
49; CGSCC-NEXT:    ret i64 [[CALL2]]
50;
51entry:
52  %conv = sext i32 %arg to i64
53  %div = sdiv i64 8, %conv
54  %call2 = call i64 @fn1(i64 %div)
55  ret i64 %call2
56}
57
58define i64 @fn2c() {
59; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
60; TUNIT-LABEL: define {{[^@]+}}@fn2c
61; TUNIT-SAME: () #[[ATTR0]] {
62; TUNIT-NEXT:  entry:
63; TUNIT-NEXT:    ret i64 42
64;
65; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
66; CGSCC-LABEL: define {{[^@]+}}@fn2c
67; CGSCC-SAME: () #[[ATTR0]] {
68; CGSCC-NEXT:  entry:
69; CGSCC-NEXT:    [[CONV:%.*]] = sext i32 undef to i64
70; CGSCC-NEXT:    [[ADD:%.*]] = add i64 42, [[CONV]]
71; CGSCC-NEXT:    [[CALL2:%.*]] = call i64 @fn1(i64 [[ADD]]) #[[ATTR2]], !range [[RNG0:![0-9]+]]
72; CGSCC-NEXT:    ret i64 [[CALL2]]
73;
74entry:
75  %conv = sext i32 undef to i64
76  %add = add i64 42, %conv
77  %call2 = call i64 @fn1(i64 %add)
78  ret i64 %call2
79}
80
81define internal i64 @fn1(i64 %p1) {
82; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
83; CGSCC-LABEL: define {{[^@]+}}@fn1
84; CGSCC-SAME: (i64 returned [[P1:%.*]]) #[[ATTR1:[0-9]+]] {
85; CGSCC-NEXT:  entry:
86; CGSCC-NEXT:    ret i64 [[P1]]
87;
88entry:
89  %tobool = icmp ne i64 %p1, 0
90  %cond = select i1 %tobool, i64 %p1, i64 %p1
91  ret i64 %cond
92}
93;.
94; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree nosync nounwind willreturn memory(none) }
95; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
96; CGSCC: attributes #[[ATTR2]] = { nofree nosync willreturn }
97;.
98; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
99;.
100; CGSCC: [[RNG0]] = !{i64 -2147483606, i64 2147483690}
101;.
102;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
103; CHECK: {{.*}}
104