1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4 2; 3; RUN: opt -passes="ipsccp<func-spec>" -funcspec-min-function-size=20 -funcspec-for-literal-constant -S < %s | FileCheck %s --check-prefix=FUNCSPEC 4; RUN: opt -passes="ipsccp<func-spec>" -funcspec-min-function-size=20 -funcspec-for-literal-constant -funcspec-max-discovery-iterations=16 -S < %s | FileCheck %s --check-prefix=NOFUNCSPEC 5 6define i64 @bar(i1 %c1, i1 %c2, i1 %c3, i1 %c4, i1 %c5, i1 %c6, i1 %c7, i1 %c8, i1 %c9, i1 %c10) { 7; FUNCSPEC-LABEL: define range(i64 4, 13) i64 @bar( 8; FUNCSPEC-SAME: i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]], i1 [[C4:%.*]], i1 [[C5:%.*]], i1 [[C6:%.*]], i1 [[C7:%.*]], i1 [[C8:%.*]], i1 [[C9:%.*]], i1 [[C10:%.*]]) { 9; FUNCSPEC-NEXT: entry: 10; FUNCSPEC-NEXT: [[F1:%.*]] = call i64 @foo.specialized.1(i64 3, i1 [[C1]], i1 [[C2]], i1 [[C3]], i1 [[C4]], i1 [[C5]], i1 [[C6]], i1 [[C7]], i1 [[C8]], i1 [[C9]], i1 [[C10]]) 11; FUNCSPEC-NEXT: [[F2:%.*]] = call i64 @foo.specialized.2(i64 4, i1 [[C1]], i1 [[C2]], i1 [[C3]], i1 [[C4]], i1 [[C5]], i1 [[C6]], i1 [[C7]], i1 [[C8]], i1 [[C9]], i1 [[C10]]) 12; FUNCSPEC-NEXT: [[ADD:%.*]] = add nuw nsw i64 [[F1]], [[F2]] 13; FUNCSPEC-NEXT: ret i64 [[ADD]] 14; 15; NOFUNCSPEC-LABEL: define range(i64 4, 13) i64 @bar( 16; NOFUNCSPEC-SAME: i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]], i1 [[C4:%.*]], i1 [[C5:%.*]], i1 [[C6:%.*]], i1 [[C7:%.*]], i1 [[C8:%.*]], i1 [[C9:%.*]], i1 [[C10:%.*]]) { 17; NOFUNCSPEC-NEXT: entry: 18; NOFUNCSPEC-NEXT: [[F1:%.*]] = call i64 @foo(i64 3, i1 [[C1]], i1 [[C2]], i1 [[C3]], i1 [[C4]], i1 [[C5]], i1 [[C6]], i1 [[C7]], i1 [[C8]], i1 [[C9]], i1 [[C10]]) 19; NOFUNCSPEC-NEXT: [[F2:%.*]] = call i64 @foo(i64 4, i1 [[C1]], i1 [[C2]], i1 [[C3]], i1 [[C4]], i1 [[C5]], i1 [[C6]], i1 [[C7]], i1 [[C8]], i1 [[C9]], i1 [[C10]]) 20; NOFUNCSPEC-NEXT: [[ADD:%.*]] = add nuw nsw i64 [[F1]], [[F2]] 21; NOFUNCSPEC-NEXT: ret i64 [[ADD]] 22; 23entry: 24 %f1 = call i64 @foo(i64 3, i1 %c1, i1 %c2, i1 %c3, i1 %c4, i1 %c5, i1 %c6, i1 %c7, i1 %c8, i1 %c9, i1 %c10) 25 %f2 = call i64 @foo(i64 4, i1 %c1, i1 %c2, i1 %c3, i1 %c4, i1 %c5, i1 %c6, i1 %c7, i1 %c8, i1 %c9, i1 %c10) 26 %add = add i64 %f1, %f2 27 ret i64 %add 28} 29 30define internal i64 @foo(i64 %n, i1 %c1, i1 %c2, i1 %c3, i1 %c4, i1 %c5, i1 %c6, i1 %c7, i1 %c8, i1 %c9, i1 %c10) { 31; NOFUNCSPEC-LABEL: define internal range(i64 2, 7) i64 @foo( 32; NOFUNCSPEC-SAME: i64 range(i64 3, 5) [[N:%.*]], i1 [[C1:%.*]], i1 [[C2:%.*]], i1 [[C3:%.*]], i1 [[C4:%.*]], i1 [[C5:%.*]], i1 [[C6:%.*]], i1 [[C7:%.*]], i1 [[C8:%.*]], i1 [[C9:%.*]], i1 [[C10:%.*]]) { 33; NOFUNCSPEC-NEXT: entry: 34; NOFUNCSPEC-NEXT: br i1 [[C1]], label [[L1:%.*]], label [[L9:%.*]] 35; NOFUNCSPEC: l1: 36; NOFUNCSPEC-NEXT: [[PHI1:%.*]] = phi i64 [ [[N]], [[ENTRY:%.*]] ], [ [[PHI2:%.*]], [[L2:%.*]] ] 37; NOFUNCSPEC-NEXT: [[ADD:%.*]] = add nuw nsw i64 [[PHI1]], 1 38; NOFUNCSPEC-NEXT: br i1 [[C2]], label [[L1_5:%.*]], label [[EXIT:%.*]] 39; NOFUNCSPEC: l1_5: 40; NOFUNCSPEC-NEXT: br i1 [[C3]], label [[L1_75:%.*]], label [[L6:%.*]] 41; NOFUNCSPEC: l1_75: 42; NOFUNCSPEC-NEXT: br i1 [[C4]], label [[L2]], label [[L3:%.*]] 43; NOFUNCSPEC: l2: 44; NOFUNCSPEC-NEXT: [[PHI2]] = phi i64 [ [[PHI1]], [[L1_75]] ], [ [[PHI3:%.*]], [[L3]] ] 45; NOFUNCSPEC-NEXT: br label [[L1]] 46; NOFUNCSPEC: l3: 47; NOFUNCSPEC-NEXT: [[PHI3]] = phi i64 [ [[PHI1]], [[L1_75]] ], [ [[PHI4:%.*]], [[L4:%.*]] ] 48; NOFUNCSPEC-NEXT: br label [[L2]] 49; NOFUNCSPEC: l4: 50; NOFUNCSPEC-NEXT: [[PHI4]] = phi i64 [ [[PHI5:%.*]], [[L5:%.*]] ], [ [[PHI6:%.*]], [[L6]] ] 51; NOFUNCSPEC-NEXT: br i1 [[C5]], label [[L3]], label [[L6]] 52; NOFUNCSPEC: l5: 53; NOFUNCSPEC-NEXT: [[PHI5]] = phi i64 [ [[PHI6]], [[L6_5:%.*]] ], [ [[PHI7:%.*]], [[L7:%.*]] ] 54; NOFUNCSPEC-NEXT: br label [[L4]] 55; NOFUNCSPEC: l6: 56; NOFUNCSPEC-NEXT: [[PHI6]] = phi i64 [ [[PHI4]], [[L4]] ], [ [[PHI1]], [[L1_5]] ] 57; NOFUNCSPEC-NEXT: br i1 [[C6]], label [[L4]], label [[L6_5]] 58; NOFUNCSPEC: l6_5: 59; NOFUNCSPEC-NEXT: br i1 [[C7]], label [[L5]], label [[L8:%.*]] 60; NOFUNCSPEC: l7: 61; NOFUNCSPEC-NEXT: [[PHI7]] = phi i64 [ [[PHI9:%.*]], [[L9]] ], [ [[PHI8:%.*]], [[L8]] ] 62; NOFUNCSPEC-NEXT: br i1 [[C8]], label [[L5]], label [[L8]] 63; NOFUNCSPEC: l8: 64; NOFUNCSPEC-NEXT: [[PHI8]] = phi i64 [ [[PHI6]], [[L6_5]] ], [ [[PHI7]], [[L7]] ] 65; NOFUNCSPEC-NEXT: br i1 [[C9]], label [[L7]], label [[L9]] 66; NOFUNCSPEC: l9: 67; NOFUNCSPEC-NEXT: [[PHI9]] = phi i64 [ [[N]], [[ENTRY]] ], [ [[PHI8]], [[L8]] ] 68; NOFUNCSPEC-NEXT: [[SUB:%.*]] = sub nuw nsw i64 [[PHI9]], 1 69; NOFUNCSPEC-NEXT: [[MUL:%.*]] = mul nuw nsw i64 [[SUB]], 2 70; NOFUNCSPEC-NEXT: br i1 [[C10]], label [[L7]], label [[EXIT]] 71; NOFUNCSPEC: exit: 72; NOFUNCSPEC-NEXT: [[RES:%.*]] = phi i64 [ 2, [[L1]] ], [ [[MUL]], [[L9]] ] 73; NOFUNCSPEC-NEXT: ret i64 [[RES]] 74; 75entry: 76 br i1 %c1, label %l1, label %l9 77 78l1: 79 %phi1 = phi i64 [ %n, %entry ], [ %phi2, %l2 ] 80 %add = add i64 %phi1, 1 81 %div = sdiv i64 %add, 2 82 br i1 %c2, label %l1_5, label %exit 83 84l1_5: 85 br i1 %c3, label %l1_75, label %l6 86 87l1_75: 88 br i1 %c4, label %l2, label %l3 89 90l2: 91 %phi2 = phi i64 [ %phi1, %l1_75 ], [ %phi3, %l3 ] 92 br label %l1 93 94l3: 95 %phi3 = phi i64 [ %phi1, %l1_75 ], [ %phi4, %l4 ] 96 br label %l2 97 98l4: 99 %phi4 = phi i64 [ %phi5, %l5 ], [ %phi6, %l6 ] 100 br i1 %c5, label %l3, label %l6 101 102l5: 103 %phi5 = phi i64 [ %phi6, %l6_5 ], [ %phi7, %l7 ] 104 br label %l4 105 106l6: 107 %phi6 = phi i64 [ %phi4, %l4 ], [ %phi1, %l1_5 ] 108 br i1 %c6, label %l4, label %l6_5 109 110l6_5: 111 br i1 %c7, label %l5, label %l8 112 113l7: 114 %phi7 = phi i64 [ %phi9, %l9 ], [ %phi8, %l8 ] 115 br i1 %c8, label %l5, label %l8 116 117l8: 118 %phi8 = phi i64 [ %phi6, %l6_5 ], [ %phi7, %l7 ] 119 br i1 %c9, label %l7, label %l9 120 121l9: 122 %phi9 = phi i64 [ %n, %entry ], [ %phi8, %l8 ] 123 %sub = sub i64 %phi9, 1 124 %mul = mul i64 %sub, 2 125 br i1 %c10, label %l7, label %exit 126 127exit: 128 %res = phi i64 [ %div, %l1 ], [ %mul, %l9] 129 ret i64 %res 130} 131 132