Florian Hahn | bee4868 | 2021-01-21 09:32:04 +0000 | [diff] [blame] | 1 | ; RUN: opt -loop-unswitch -loop-unswitch-memoryssa-threshold=0 -memssa-check-limit=1 -enable-new-pm=0 -S %s | FileCheck --check-prefix=THRESHOLD-0 %s |
| 2 | ; RUN: opt -loop-unswitch -memssa-check-limit=1 -S -enable-new-pm=0 %s | FileCheck --check-prefix=THRESHOLD-DEFAULT %s |
| 3 | |
| 4 | ; Make sure -loop-unswitch-memoryssa-threshold works. The test uses |
| 5 | ; -memssa-check-limit=1 to effectively disable any MemorySSA optimizations |
| 6 | ; on construction, so the test can be kept simple. |
| 7 | |
| 8 | declare void @clobber() |
| 9 | |
| 10 | ; Partial unswitching is possible, because the store in %noclobber does not |
| 11 | ; alias the load of the condition. |
| 12 | define i32 @partial_unswitch_true_successor_noclobber(i32* noalias %ptr.1, i32* noalias %ptr.2, i32 %N) { |
| 13 | ; THRESHOLD-0-LABEL: @partial_unswitch_true_successor |
| 14 | ; THRESHOLD-0: entry: |
| 15 | ; THRESHOLD-0: br label %loop.header |
| 16 | ; |
| 17 | ; THRESHOLD-DEFAULT-LABEL: @partial_unswitch_true_successor |
| 18 | ; THRESHOLD-DEFAULT-NEXT: entry: |
| 19 | ; THRESHOLD-DEFAULT-NEXT: [[LV:%[0-9]+]] = load i32, i32* %ptr.1, align 4 |
| 20 | ; THRESHOLD-DEFAULT-NEXT: [[C:%[0-9]+]] = icmp eq i32 [[LV]], 100 |
| 21 | ; THRESHOLD-DEFAULT-NEXT: br i1 [[C]] |
| 22 | ; |
| 23 | entry: |
| 24 | br label %loop.header |
| 25 | |
| 26 | loop.header: |
| 27 | %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ] |
| 28 | %lv = load i32, i32* %ptr.1 |
| 29 | %sc = icmp eq i32 %lv, 100 |
| 30 | br i1 %sc, label %noclobber, label %clobber |
| 31 | |
| 32 | noclobber: |
| 33 | %gep.1 = getelementptr i32, i32* %ptr.2, i32 %iv |
| 34 | store i32 %lv, i32* %gep.1 |
| 35 | br label %loop.latch |
| 36 | |
| 37 | clobber: |
| 38 | call void @clobber() |
| 39 | br label %loop.latch |
| 40 | |
| 41 | loop.latch: |
| 42 | %c = icmp ult i32 %iv, %N |
| 43 | %iv.next = add i32 %iv, 1 |
| 44 | br i1 %c, label %loop.header, label %exit |
| 45 | |
| 46 | exit: |
| 47 | ret i32 10 |
| 48 | } |