|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -p loop-unroll -scev-cheap-expansion-budget=2 -S %s | FileCheck --check-prefix=BUDGET2 %s |
| 3 | +; RUN: opt -p loop-unroll -scev-cheap-expansion-budget=3 -S %s | FileCheck --check-prefix=BUDGET3 %s |
| 4 | + |
| 5 | +define i32 @test_expansion_cost_2(i32 %start, i32 %end) { |
| 6 | +; BUDGET2-LABEL: define i32 @test_expansion_cost_2( |
| 7 | +; BUDGET2-SAME: i32 [[START:%.*]], i32 [[END:%.*]]) { |
| 8 | +; BUDGET2-NEXT: [[ENTRY:.*]]: |
| 9 | +; BUDGET2-NEXT: [[SUB:%.*]] = add i32 [[END]], -1 |
| 10 | +; BUDGET2-NEXT: br label %[[LOOP_HEADER:.*]] |
| 11 | +; BUDGET2: [[LOOP_HEADER]]: |
| 12 | +; BUDGET2-NEXT: [[IV:%.*]] = phi i32 [ [[START]], %[[ENTRY]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ] |
| 13 | +; BUDGET2-NEXT: [[C:%.*]] = icmp eq i32 [[IV]], [[SUB]] |
| 14 | +; BUDGET2-NEXT: br i1 [[C]], label %[[THEN:.*]], label %[[LOOP_LATCH]] |
| 15 | +; BUDGET2: [[THEN]]: |
| 16 | +; BUDGET2-NEXT: br label %[[LOOP_LATCH]] |
| 17 | +; BUDGET2: [[LOOP_LATCH]]: |
| 18 | +; BUDGET2-NEXT: [[IV_NEXT]] = add nsw i32 [[IV]], 1 |
| 19 | +; BUDGET2-NEXT: [[EC:%.*]] = icmp eq i32 [[IV_NEXT]], [[END]] |
| 20 | +; BUDGET2-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]] |
| 21 | +; BUDGET2: [[EXIT]]: |
| 22 | +; BUDGET2-NEXT: ret i32 0 |
| 23 | +; |
| 24 | +; BUDGET3-LABEL: define i32 @test_expansion_cost_2( |
| 25 | +; BUDGET3-SAME: i32 [[START:%.*]], i32 [[END:%.*]]) { |
| 26 | +; BUDGET3-NEXT: [[ENTRY:.*]]: |
| 27 | +; BUDGET3-NEXT: [[SUB:%.*]] = add i32 [[END]], -1 |
| 28 | +; BUDGET3-NEXT: br label %[[LOOP_HEADER:.*]] |
| 29 | +; BUDGET3: [[LOOP_HEADER]]: |
| 30 | +; BUDGET3-NEXT: [[TMP3:%.*]] = phi i32 [ [[START]], %[[ENTRY]] ], [ [[IV_NEXT_PEEL:%.*]], %[[LOOP_LATCH:.*]] ] |
| 31 | +; BUDGET3-NEXT: [[C_PEEL:%.*]] = icmp eq i32 [[TMP3]], [[SUB]] |
| 32 | +; BUDGET3-NEXT: br i1 [[C_PEEL]], label %[[THEN:.*]], label %[[LOOP_LATCH]] |
| 33 | +; BUDGET3: [[THEN]]: |
| 34 | +; BUDGET3-NEXT: br label %[[LOOP_LATCH]] |
| 35 | +; BUDGET3: [[LOOP_LATCH]]: |
| 36 | +; BUDGET3-NEXT: [[IV_NEXT_PEEL]] = add nsw i32 [[TMP3]], 1 |
| 37 | +; BUDGET3-NEXT: [[EC_PEEL:%.*]] = icmp eq i32 [[IV_NEXT_PEEL]], [[END]] |
| 38 | +; BUDGET3-NEXT: br i1 [[EC_PEEL]], label %[[EXIT:.*]], label %[[LOOP_HEADER]] |
| 39 | +; BUDGET3: [[EXIT]]: |
| 40 | +; BUDGET3-NEXT: ret i32 0 |
| 41 | +; |
| 42 | +entry: |
| 43 | + %sub = add i32 %end, -1 |
| 44 | + br label %loop.header |
| 45 | + |
| 46 | +loop.header: |
| 47 | + %iv = phi i32 [ %start, %entry ], [ %iv.next, %loop.latch ] |
| 48 | + %c = icmp eq i32 %iv, %sub |
| 49 | + br i1 %c, label %then, label %loop.latch |
| 50 | + |
| 51 | +then: |
| 52 | + br label %loop.latch |
| 53 | + |
| 54 | +loop.latch: |
| 55 | + %iv.next = add nsw i32 %iv, 1 |
| 56 | + %ec = icmp eq i32 %iv.next, %end |
| 57 | + br i1 %ec, label %exit, label %loop.header |
| 58 | + |
| 59 | +exit: |
| 60 | + ret i32 0 |
| 61 | +} |
0 commit comments