1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes
2; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM
3; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM
4; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM
5; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM
6
7; FIXME: DOT should be replaced with 3
8
9define i32 @test-ashr(i32 %c) {
10; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
11; IS__TUNIT____-LABEL: define {{[^@]+}}@test-ashr
12; IS__TUNIT____-SAME: (i32 [[C:%.*]]) [[ATTR0:#.*]] {
13; IS__TUNIT____-NEXT:  chk65:
14; IS__TUNIT____-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[C]], 65
15; IS__TUNIT____-NEXT:    br i1 [[CMP]], label [[RETURN:%.*]], label [[CHK0:%.*]]
16; IS__TUNIT____:       chk0:
17; IS__TUNIT____-NEXT:    [[CMP1:%.*]] = icmp slt i32 [[C]], 0
18; IS__TUNIT____-NEXT:    br i1 [[CMP]], label [[RETURN]], label [[BB_IF:%.*]]
19; IS__TUNIT____:       bb_if:
20; IS__TUNIT____-NEXT:    [[ASHR_VAL:%.*]] = ashr exact i32 [[C]], 2
21; IS__TUNIT____-NEXT:    [[CMP2:%.*]] = icmp sgt i32 [[ASHR_VAL]], 15
22; IS__TUNIT____-NEXT:    br i1 [[CMP2]], label [[BB_THEN:%.*]], label [[RETURN]]
23; IS__TUNIT____:       bb_then:
24; IS__TUNIT____-NEXT:    [[CMP3:%.*]] = icmp eq i32 [[ASHR_VAL]], 16
25; IS__TUNIT____-NEXT:    [[DOT:%.*]] = select i1 [[CMP3]], i32 3, i32 2
26; IS__TUNIT____-NEXT:    br label [[RETURN]]
27; IS__TUNIT____:       return:
28; IS__TUNIT____-NEXT:    [[RETVAL:%.*]] = phi i32 [ 0, [[CHK65:%.*]] ], [ 1, [[CHK0]] ], [ [[DOT]], [[BB_THEN]] ], [ 4, [[BB_IF]] ]
29; IS__TUNIT____-NEXT:    ret i32 [[RETVAL]]
30;
31; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
32; IS__CGSCC____-LABEL: define {{[^@]+}}@test-ashr
33; IS__CGSCC____-SAME: (i32 [[C:%.*]]) [[ATTR0:#.*]] {
34; IS__CGSCC____-NEXT:  chk65:
35; IS__CGSCC____-NEXT:    [[CMP:%.*]] = icmp sgt i32 [[C]], 65
36; IS__CGSCC____-NEXT:    br i1 [[CMP]], label [[RETURN:%.*]], label [[CHK0:%.*]]
37; IS__CGSCC____:       chk0:
38; IS__CGSCC____-NEXT:    [[CMP1:%.*]] = icmp slt i32 [[C]], 0
39; IS__CGSCC____-NEXT:    br i1 [[CMP]], label [[RETURN]], label [[BB_IF:%.*]]
40; IS__CGSCC____:       bb_if:
41; IS__CGSCC____-NEXT:    [[ASHR_VAL:%.*]] = ashr exact i32 [[C]], 2
42; IS__CGSCC____-NEXT:    [[CMP2:%.*]] = icmp sgt i32 [[ASHR_VAL]], 15
43; IS__CGSCC____-NEXT:    br i1 [[CMP2]], label [[BB_THEN:%.*]], label [[RETURN]]
44; IS__CGSCC____:       bb_then:
45; IS__CGSCC____-NEXT:    [[CMP3:%.*]] = icmp eq i32 [[ASHR_VAL]], 16
46; IS__CGSCC____-NEXT:    [[DOT:%.*]] = select i1 [[CMP3]], i32 3, i32 2
47; IS__CGSCC____-NEXT:    br label [[RETURN]]
48; IS__CGSCC____:       return:
49; IS__CGSCC____-NEXT:    [[RETVAL:%.*]] = phi i32 [ 0, [[CHK65:%.*]] ], [ 1, [[CHK0]] ], [ [[DOT]], [[BB_THEN]] ], [ 4, [[BB_IF]] ]
50; IS__CGSCC____-NEXT:    ret i32 [[RETVAL]]
51;
52chk65:
53  %cmp = icmp sgt i32 %c, 65
54  br i1 %cmp, label %return, label %chk0
55
56chk0:
57  %cmp1 = icmp slt i32 %c, 0
58  br i1 %cmp, label %return, label %bb_if
59
60bb_if:
61  %ashr.val = ashr exact i32 %c, 2
62  %cmp2 = icmp sgt i32 %ashr.val, 15
63  br i1 %cmp2, label %bb_then, label %return
64
65bb_then:
66  %cmp3 = icmp eq i32 %ashr.val, 16
67  %. = select i1 %cmp3, i32 3, i32 2
68  br label %return
69
70return:
71  %retval = phi i32 [0, %chk65], [1, %chk0], [%., %bb_then], [4, %bb_if]
72  ret i32 %retval
73}
74