|
| 1 | +; This test documents how the IR dumped for loop passes differs with -print-loop-func-scope |
| 2 | +; and -print-module-scope |
| 3 | +; - Without -print-loop-func-scope, dumps only the loop, with 3 sections- preheader, |
| 4 | +; loop, and exit blocks |
| 5 | +; - With -print-loop-func-scope, dumps only the function which contains the loop |
| 6 | +; - With -print-module-scope, dumps the entire module containing the loop, and disregards |
| 7 | +; the -print-loop-func-scope flag. |
| 8 | + |
| 9 | +; RUN: opt < %s 2>&1 -disable-output \ |
| 10 | +; RUN: -passes=licm -print-after=licm\ |
| 11 | +; RUN: | FileCheck %s -check-prefix=VANILLA |
| 12 | +; RUN: opt < %s 2>&1 -disable-output \ |
| 13 | +; RUN: -passes=licm -print-after=licm -print-loop-func-scope \ |
| 14 | +; RUN: | FileCheck %s -check-prefix=LOOPFUNC |
| 15 | +; RUN: opt < %s 2>&1 -disable-output \ |
| 16 | +; RUN: -passes=licm -print-after=licm -print-module-scope \ |
| 17 | +; RUN: | FileCheck %s -check-prefix=MODULE |
| 18 | +; RUN: opt < %s 2>&1 -disable-output \ |
| 19 | +; RUN: -passes=licm -print-after=licm -print-module-scope -print-loop-func-scope\ |
| 20 | +; RUN: | FileCheck %s -check-prefix=MODULEWITHLOOP |
| 21 | + |
| 22 | +; VANILLA: IR Dump After LICMPass |
| 23 | +; VANILLA-NOT: define void @foo |
| 24 | +; VANILLA: Preheader: |
| 25 | +; VANILLA: Loop: |
| 26 | +; VANILLA: Exit blocks |
| 27 | + |
| 28 | +; LOOPFUNC: IR Dump After LICMPass |
| 29 | +; LOOPFUNC: (loop: |
| 30 | +; LOOPFUNC: define void @foo |
| 31 | +; LOOPFUNC-NOT: Preheader: |
| 32 | +; LOOPFUNC-NOT: Loop: |
| 33 | +; LOOPFUNC-NOT: Exit blocks |
| 34 | + |
| 35 | +; MODULE: IR Dump After LICMPass |
| 36 | +; MODULE: ModuleID = |
| 37 | +; MODULE: define void @foo |
| 38 | +; MODULE-NOT: Preheader: |
| 39 | +; MODULE-NOT: Loop: |
| 40 | +; MODULE-NOT: Exit blocks |
| 41 | +; MODULE: define void @bar |
| 42 | + |
| 43 | +; MODULEWITHLOOP: IR Dump After LICMPass |
| 44 | +; MODULEWITHLOOP: ModuleID = |
| 45 | +; MODULEWITHLOOP: define void @foo |
| 46 | +; MODULEWITHLOOP-NOT: Preheader: |
| 47 | +; MODULEWITHLOOP-NOT: Loop: |
| 48 | +; MODULEWITHLOOP-NOT: Exit blocks |
| 49 | +; MODULEWITHLOOP: define void @bar |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | +define void @foo(i32 %0, i32 %1, i32* %2) { |
| 54 | + %4 = icmp sgt i32 %0, 0 |
| 55 | + br i1 %4, label %5, label %8 |
| 56 | + |
| 57 | +5: ; preds = %3 |
| 58 | + br label %12 |
| 59 | + |
| 60 | +6: ; preds = %12 |
| 61 | + %7 = phi i32 [ %15, %12 ] |
| 62 | + br label %8 |
| 63 | + |
| 64 | +8: ; preds = %6, %3 |
| 65 | + %9 = phi i32 [ 1, %3 ], [ %7, %6 ] |
| 66 | + %10 = add nsw i32 %1, %0 |
| 67 | + %11 = add nsw i32 %10, %9 |
| 68 | + store i32 %11, i32* %2, align 4 |
| 69 | + ret void |
| 70 | + |
| 71 | +12: ; preds = %5, %12 |
| 72 | + %13 = phi i32 [ %16, %12 ], [ 0, %5 ] |
| 73 | + %14 = phi i32 [ %15, %12 ], [ 1, %5 ] |
| 74 | + %15 = mul nsw i32 %14, %1 |
| 75 | + %16 = add nuw nsw i32 %13, 1 |
| 76 | + %17 = icmp eq i32 %16, %0 |
| 77 | + br i1 %17, label %6, label %12 |
| 78 | +} |
| 79 | + |
| 80 | +define void @bar() { |
| 81 | + ret void |
| 82 | +} |
0 commit comments