1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes --check-globals 2; call site specific analysis is disabled 3 4; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM 5 6; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM 7 8; 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 9 10; 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 11 12define i32 @test_range(i32 %unknown) { 13; CHECK-LABEL: define {{[^@]+}}@test_range 14; CHECK-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR0:[0-9]+]] { 15; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[UNKNOWN]], 100 16; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 100, i32 0 17; CHECK-NEXT: ret i32 [[TMP2]] 18; 19 %1 = icmp sgt i32 %unknown, 100 20 %2 = select i1 %1, i32 100, i32 0 21 ret i32 %2 22} 23 24define i32 @test1(i32 %unknown, i32 %b) { 25; IS__TUNIT____-LABEL: define {{[^@]+}}@test1 26; IS__TUNIT____-SAME: (i32 [[UNKNOWN:%.*]], i32 [[B:%.*]]) #[[ATTR0]] { 27; IS__TUNIT____-NEXT: [[TMP1:%.*]] = call i32 @test_range(i32 [[UNKNOWN]]) 28; IS__TUNIT____-NEXT: [[TMP2:%.*]] = sub nsw i32 [[TMP1]], [[B]] 29; IS__TUNIT____-NEXT: ret i32 [[TMP2]] 30; 31; IS__CGSCC____-LABEL: define {{[^@]+}}@test1 32; IS__CGSCC____-SAME: (i32 [[UNKNOWN:%.*]], i32 [[B:%.*]]) #[[ATTR1:[0-9]+]] { 33; IS__CGSCC____-NEXT: [[TMP1:%.*]] = call i32 @test_range(i32 [[UNKNOWN]]) 34; IS__CGSCC____-NEXT: [[TMP2:%.*]] = sub nsw i32 [[TMP1]], [[B]] 35; IS__CGSCC____-NEXT: ret i32 [[TMP2]] 36; 37 %1 = call i32 @test_range(i32 %unknown) 38 %2 = sub nsw i32 %1, %b 39 ret i32 %2 40} 41 42define i32 @test2(i32 %unknown, i32 %b) { 43; IS__TUNIT____-LABEL: define {{[^@]+}}@test2 44; IS__TUNIT____-SAME: (i32 [[UNKNOWN:%.*]], i32 [[B:%.*]]) #[[ATTR0]] { 45; IS__TUNIT____-NEXT: [[TMP1:%.*]] = call i32 @test_range(i32 [[UNKNOWN]]) 46; IS__TUNIT____-NEXT: [[TMP2:%.*]] = add nsw i32 [[TMP1]], [[B]] 47; IS__TUNIT____-NEXT: ret i32 [[TMP2]] 48; 49; IS__CGSCC____-LABEL: define {{[^@]+}}@test2 50; IS__CGSCC____-SAME: (i32 [[UNKNOWN:%.*]], i32 [[B:%.*]]) #[[ATTR1]] { 51; IS__CGSCC____-NEXT: [[TMP1:%.*]] = call i32 @test_range(i32 [[UNKNOWN]]) 52; IS__CGSCC____-NEXT: [[TMP2:%.*]] = add nsw i32 [[TMP1]], [[B]] 53; IS__CGSCC____-NEXT: ret i32 [[TMP2]] 54; 55 %1 = call i32 @test_range(i32 %unknown) 56 %2 = add nsw i32 %1, %b 57 ret i32 %2 58} 59 60; Positive checks 61 62define i32 @test1_pcheck(i32 %unknown) { 63; IS__TUNIT____-LABEL: define {{[^@]+}}@test1_pcheck 64; IS__TUNIT____-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR0]] { 65; IS__TUNIT____-NEXT: [[TMP1:%.*]] = call i32 @test1(i32 [[UNKNOWN]], i32 noundef 20) 66; IS__TUNIT____-NEXT: [[TMP2:%.*]] = icmp sle i32 [[TMP1]], 90 67; IS__TUNIT____-NEXT: [[TMP3:%.*]] = zext i1 [[TMP2]] to i32 68; IS__TUNIT____-NEXT: ret i32 [[TMP3]] 69; 70; IS__CGSCC____-LABEL: define {{[^@]+}}@test1_pcheck 71; IS__CGSCC____-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR1]] { 72; IS__CGSCC____-NEXT: [[TMP1:%.*]] = call i32 @test1(i32 [[UNKNOWN]], i32 noundef 20) 73; IS__CGSCC____-NEXT: [[TMP2:%.*]] = icmp sle i32 [[TMP1]], 90 74; IS__CGSCC____-NEXT: [[TMP3:%.*]] = zext i1 [[TMP2]] to i32 75; IS__CGSCC____-NEXT: ret i32 [[TMP3]] 76; 77 %1 = call i32 @test1(i32 %unknown, i32 20) 78 %2 = icmp sle i32 %1, 90 79 %3 = zext i1 %2 to i32 80 ret i32 %3 81} 82 83define i32 @test2_pcheck(i32 %unknown) { 84; IS__TUNIT____-LABEL: define {{[^@]+}}@test2_pcheck 85; IS__TUNIT____-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR0]] { 86; IS__TUNIT____-NEXT: [[TMP1:%.*]] = call i32 @test2(i32 [[UNKNOWN]], i32 noundef 20) 87; IS__TUNIT____-NEXT: [[TMP2:%.*]] = icmp sge i32 [[TMP1]], 20 88; IS__TUNIT____-NEXT: [[TMP3:%.*]] = zext i1 [[TMP2]] to i32 89; IS__TUNIT____-NEXT: ret i32 [[TMP3]] 90; 91; IS__CGSCC____-LABEL: define {{[^@]+}}@test2_pcheck 92; IS__CGSCC____-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR1]] { 93; IS__CGSCC____-NEXT: [[TMP1:%.*]] = call i32 @test2(i32 [[UNKNOWN]], i32 noundef 20) 94; IS__CGSCC____-NEXT: [[TMP2:%.*]] = icmp sge i32 [[TMP1]], 20 95; IS__CGSCC____-NEXT: [[TMP3:%.*]] = zext i1 [[TMP2]] to i32 96; IS__CGSCC____-NEXT: ret i32 [[TMP3]] 97; 98 %1 = call i32 @test2(i32 %unknown, i32 20) 99 %2 = icmp sge i32 %1, 20 100 %3 = zext i1 %2 to i32 101 ret i32 %3 102} 103 104; Negative checks 105 106define i32 @test1_ncheck(i32 %unknown) { 107; IS__TUNIT____-LABEL: define {{[^@]+}}@test1_ncheck 108; IS__TUNIT____-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR0]] { 109; IS__TUNIT____-NEXT: [[TMP1:%.*]] = call i32 @test1(i32 [[UNKNOWN]], i32 noundef 20) 110; IS__TUNIT____-NEXT: [[TMP2:%.*]] = icmp sle i32 [[TMP1]], 10 111; IS__TUNIT____-NEXT: [[TMP3:%.*]] = zext i1 [[TMP2]] to i32 112; IS__TUNIT____-NEXT: ret i32 [[TMP3]] 113; 114; IS__CGSCC____-LABEL: define {{[^@]+}}@test1_ncheck 115; IS__CGSCC____-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR1]] { 116; IS__CGSCC____-NEXT: [[TMP1:%.*]] = call i32 @test1(i32 [[UNKNOWN]], i32 noundef 20) 117; IS__CGSCC____-NEXT: [[TMP2:%.*]] = icmp sle i32 [[TMP1]], 10 118; IS__CGSCC____-NEXT: [[TMP3:%.*]] = zext i1 [[TMP2]] to i32 119; IS__CGSCC____-NEXT: ret i32 [[TMP3]] 120; 121 %1 = call i32 @test1(i32 %unknown, i32 20) 122 %2 = icmp sle i32 %1, 10 123 %3 = zext i1 %2 to i32 124 ret i32 %3 125} 126 127define i32 @test2_ncheck(i32 %unknown) { 128; IS__TUNIT____-LABEL: define {{[^@]+}}@test2_ncheck 129; IS__TUNIT____-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR0]] { 130; IS__TUNIT____-NEXT: [[TMP1:%.*]] = call i32 @test2(i32 [[UNKNOWN]], i32 noundef 20) 131; IS__TUNIT____-NEXT: [[TMP2:%.*]] = icmp sge i32 [[TMP1]], 30 132; IS__TUNIT____-NEXT: [[TMP3:%.*]] = zext i1 [[TMP2]] to i32 133; IS__TUNIT____-NEXT: ret i32 [[TMP3]] 134; 135; IS__CGSCC____-LABEL: define {{[^@]+}}@test2_ncheck 136; IS__CGSCC____-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR1]] { 137; IS__CGSCC____-NEXT: [[TMP1:%.*]] = call i32 @test2(i32 [[UNKNOWN]], i32 noundef 20) 138; IS__CGSCC____-NEXT: [[TMP2:%.*]] = icmp sge i32 [[TMP1]], 30 139; IS__CGSCC____-NEXT: [[TMP3:%.*]] = zext i1 [[TMP2]] to i32 140; IS__CGSCC____-NEXT: ret i32 [[TMP3]] 141; 142 %1 = call i32 @test2(i32 %unknown, i32 20) 143 %2 = icmp sge i32 %1, 30 144 %3 = zext i1 %2 to i32 145 ret i32 %3 146} 147;. 148; IS__TUNIT____: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind readnone willreturn } 149; IS__TUNIT____: attributes #[[ATTR1:[0-9]+]] = { nofree nosync nounwind readnone willreturn } 150;. 151; IS__CGSCC____: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind readnone willreturn } 152; IS__CGSCC____: attributes #[[ATTR1]] = { nofree nosync nounwind readnone willreturn } 153; IS__CGSCC____: attributes #[[ATTR2:[0-9]+]] = { readnone willreturn } 154;. 155