brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.3 KiB · 934032b Raw
155 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes --check-globals2; call site specific analysis is enabled3 4; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-enable-call-site-specific-deduction=true -attributor-manifest-internal  -attributor-annotate-decl-cs  -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT5 6; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-enable-call-site-specific-deduction=true -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC7 8define i32 @test_range(i32 %unknown) {9; CHECK-LABEL: define {{[^@]+}}@test_range10; CHECK-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR0:[0-9]+]] {11; CHECK-NEXT:    [[TMP1:%.*]] = icmp sgt i32 [[UNKNOWN]], 10012; CHECK-NEXT:    [[TMP2:%.*]] = select i1 [[TMP1]], i32 100, i32 013; CHECK-NEXT:    ret i32 [[TMP2]]14;15  %1 = icmp sgt i32 %unknown, 10016  %2 = select i1 %1, i32 100, i32 017  ret i32 %218}19 20define i32 @test1(i32 %unknown, i32 %b) {21; TUNIT-LABEL: define {{[^@]+}}@test122; TUNIT-SAME: (i32 [[UNKNOWN:%.*]], i32 [[B:%.*]]) #[[ATTR0]] {23; TUNIT-NEXT:    [[TMP1:%.*]] = call i32 @test_range(i32 [[UNKNOWN]])24; TUNIT-NEXT:    [[TMP2:%.*]] = sub nsw i32 [[TMP1]], [[B]]25; TUNIT-NEXT:    ret i32 [[TMP2]]26;27; CGSCC-LABEL: define {{[^@]+}}@test128; CGSCC-SAME: (i32 [[UNKNOWN:%.*]], i32 [[B:%.*]]) #[[ATTR1:[0-9]+]] {29; CGSCC-NEXT:    [[TMP1:%.*]] = call i32 @test_range(i32 [[UNKNOWN]])30; CGSCC-NEXT:    [[TMP2:%.*]] = sub nsw i32 [[TMP1]], [[B]]31; CGSCC-NEXT:    ret i32 [[TMP2]]32;33  %1 = call i32 @test_range(i32 %unknown)34  %2 = sub nsw i32 %1, %b35  ret i32 %236}37 38define i32 @test2(i32 %unknown, i32 %b) {39; TUNIT-LABEL: define {{[^@]+}}@test240; TUNIT-SAME: (i32 [[UNKNOWN:%.*]], i32 [[B:%.*]]) #[[ATTR0]] {41; TUNIT-NEXT:    [[TMP1:%.*]] = call i32 @test_range(i32 [[UNKNOWN]])42; TUNIT-NEXT:    [[TMP2:%.*]] = add nsw i32 [[TMP1]], [[B]]43; TUNIT-NEXT:    ret i32 [[TMP2]]44;45; CGSCC-LABEL: define {{[^@]+}}@test246; CGSCC-SAME: (i32 [[UNKNOWN:%.*]], i32 [[B:%.*]]) #[[ATTR1]] {47; CGSCC-NEXT:    [[TMP1:%.*]] = call i32 @test_range(i32 [[UNKNOWN]])48; CGSCC-NEXT:    [[TMP2:%.*]] = add nsw i32 [[TMP1]], [[B]]49; CGSCC-NEXT:    ret i32 [[TMP2]]50;51  %1 = call i32 @test_range(i32 %unknown)52  %2 = add nsw i32 %1, %b53  ret i32 %254}55 56; Positive checks57 58; FIXME: AAValueSimplify preserves the context but simplifies to a value in the other function, I think.59;        Either way, as we settle on the new AAValueSimplifyReturned scheme that replaces AAReturnedValues60;        we need to look into this again. For the purpose of making some progress we take this regression61;        for now, call site contexts are not on by default anyway (yet).62define i32 @test1_pcheck(i32 %unknown) {63; TUNIT-LABEL: define {{[^@]+}}@test1_pcheck64; TUNIT-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR0]] {65; TUNIT-NEXT:    [[TMP1:%.*]] = call i32 @test1(i32 [[UNKNOWN]], i32 noundef 20)66; TUNIT-NEXT:    [[TMP2:%.*]] = icmp sle i32 [[TMP1]], 9067; TUNIT-NEXT:    [[TMP3:%.*]] = zext i1 [[TMP2]] to i3268; TUNIT-NEXT:    ret i32 [[TMP3]]69;70; CGSCC-LABEL: define {{[^@]+}}@test1_pcheck71; CGSCC-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR1]] {72; CGSCC-NEXT:    [[TMP1:%.*]] = call i32 @test1(i32 [[UNKNOWN]], i32 noundef 20)73; CGSCC-NEXT:    [[TMP2:%.*]] = icmp sle i32 [[TMP1]], 9074; CGSCC-NEXT:    [[TMP3:%.*]] = zext i1 [[TMP2]] to i3275; CGSCC-NEXT:    ret i32 [[TMP3]]76;77  %1 = call i32 @test1(i32 %unknown, i32 20)78  %2 = icmp sle i32 %1, 9079  %3 = zext i1 %2 to i3280  ret i32 %381}82 83define i32 @test2_pcheck(i32 %unknown) {84; TUNIT-LABEL: define {{[^@]+}}@test2_pcheck85; TUNIT-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR0]] {86; TUNIT-NEXT:    [[TMP1:%.*]] = call i32 @test2(i32 [[UNKNOWN]], i32 noundef 20)87; TUNIT-NEXT:    [[TMP2:%.*]] = icmp sge i32 [[TMP1]], 2088; TUNIT-NEXT:    [[TMP3:%.*]] = zext i1 [[TMP2]] to i3289; TUNIT-NEXT:    ret i32 [[TMP3]]90;91; CGSCC-LABEL: define {{[^@]+}}@test2_pcheck92; CGSCC-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR1]] {93; CGSCC-NEXT:    [[TMP1:%.*]] = call i32 @test2(i32 [[UNKNOWN]], i32 noundef 20)94; CGSCC-NEXT:    [[TMP2:%.*]] = icmp sge i32 [[TMP1]], 2095; CGSCC-NEXT:    [[TMP3:%.*]] = zext i1 [[TMP2]] to i3296; CGSCC-NEXT:    ret i32 [[TMP3]]97;98  %1 = call i32 @test2(i32 %unknown, i32 20)99  %2 = icmp sge i32 %1, 20100  %3 = zext i1 %2 to i32101  ret i32 %3102}103 104; Negative checks105 106define i32 @test1_ncheck(i32 %unknown) {107; TUNIT-LABEL: define {{[^@]+}}@test1_ncheck108; TUNIT-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR0]] {109; TUNIT-NEXT:    [[TMP1:%.*]] = call i32 @test1(i32 [[UNKNOWN]], i32 noundef 20)110; TUNIT-NEXT:    [[TMP2:%.*]] = icmp sle i32 [[TMP1]], 10111; TUNIT-NEXT:    [[TMP3:%.*]] = zext i1 [[TMP2]] to i32112; TUNIT-NEXT:    ret i32 [[TMP3]]113;114; CGSCC-LABEL: define {{[^@]+}}@test1_ncheck115; CGSCC-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR1]] {116; CGSCC-NEXT:    [[TMP1:%.*]] = call i32 @test1(i32 [[UNKNOWN]], i32 noundef 20)117; CGSCC-NEXT:    [[TMP2:%.*]] = icmp sle i32 [[TMP1]], 10118; CGSCC-NEXT:    [[TMP3:%.*]] = zext i1 [[TMP2]] to i32119; CGSCC-NEXT:    ret i32 [[TMP3]]120;121  %1 = call i32 @test1(i32 %unknown, i32 20)122  %2 = icmp sle i32 %1, 10123  %3 = zext i1 %2 to i32124  ret i32 %3125}126 127define i32 @test2_ncheck(i32 %unknown) {128; TUNIT-LABEL: define {{[^@]+}}@test2_ncheck129; TUNIT-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR0]] {130; TUNIT-NEXT:    [[TMP1:%.*]] = call i32 @test2(i32 [[UNKNOWN]], i32 noundef 20)131; TUNIT-NEXT:    [[TMP2:%.*]] = icmp sge i32 [[TMP1]], 30132; TUNIT-NEXT:    [[TMP3:%.*]] = zext i1 [[TMP2]] to i32133; TUNIT-NEXT:    ret i32 [[TMP3]]134;135; CGSCC-LABEL: define {{[^@]+}}@test2_ncheck136; CGSCC-SAME: (i32 [[UNKNOWN:%.*]]) #[[ATTR1]] {137; CGSCC-NEXT:    [[TMP1:%.*]] = call i32 @test2(i32 [[UNKNOWN]], i32 noundef 20)138; CGSCC-NEXT:    [[TMP2:%.*]] = icmp sge i32 [[TMP1]], 30139; CGSCC-NEXT:    [[TMP3:%.*]] = zext i1 [[TMP2]] to i32140; CGSCC-NEXT:    ret i32 [[TMP3]]141;142  %1 = call i32 @test2(i32 %unknown, i32 20)143  %2 = icmp sge i32 %1, 30144  %3 = zext i1 %2 to i32145  ret i32 %3146}147;.148; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }149; TUNIT: attributes #[[ATTR1:[0-9]+]] = { nofree nosync nounwind willreturn memory(none) }150;.151; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }152; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(none) }153; CGSCC: attributes #[[ATTR2:[0-9]+]] = { nofree nosync willreturn }154;.155