1 ; RUN: opt -passes='loop-mssa(simple-loop-unswitch<nontrivial>),verify<loops>' -verify-dom-info -verify-memoryssa -S %s | FileCheck %s
2 ; RUN: opt -passes='loop-mssa(simple-loop-unswitch<nontrivial>),verify<loops>' -memssa-check-limit=3 -verify-dom-info -verify-memoryssa -S %s | FileCheck %s
4 declare void @clobber()
6 ; Check that MemorySSA updating can deal with a clobbering access of a
7 ; duplicated load being a MemoryPHI outside the loop.
8 define void @partial_unswitch_memssa_update(ptr noalias %ptr, i1 %c) {
9 ; CHECK-LABEL: @partial_unswitch_memssa_update(
10 ; CHECK-LABEL: loop.ph:
11 ; CHECK-NEXT: [[LV:%[a-z0-9]+]] = load i32, ptr %ptr, align 4
12 ; CHECK-NEXT: [[C:%[a-z0-9]+]] = icmp eq i32 [[LV]], 0
13 ; CHECK-NEXT: br i1 [[C]]
15 br i1 %c, label %loop.ph, label %outside.clobber
25 %lv = load i32, ptr %ptr, align 4
26 %hc = icmp eq i32 %lv, 0
27 br i1 %hc, label %if, label %then
36 br i1 true, label %loop.header, label %exit
42 ; Check that MemorySSA updating can deal with skipping defining accesses in the
43 ; loop body until it finds the first defining access outside the loop.
44 define void @partial_unswitch_inloop_stores_beteween_outside_defining_access(ptr noalias %ptr, ptr noalias %src) {
45 ; CHECK-LABEL: @partial_unswitch_inloop_stores_beteween_outside_defining_access
47 ; CHECK-NEXT: store i64 0, ptr %ptr, align 1
48 ; CHECK-NEXT: store i64 1, ptr %ptr, align 1
49 ; CHECK-NEXT: [[LV:%[a-z0-9]+]] = load i16, ptr %src, align 1
50 ; CHECK-NEXT: [[C:%[a-z0-9]+]] = icmp eq i16 [[LV]], 0
51 ; CHECK-NEXT: br i1 [[C]]
54 store i64 0, ptr %ptr, align 1
55 store i64 1, ptr %ptr, align 1
59 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
60 store i64 2, ptr %ptr, align 1
61 %lv = load i16, ptr %src, align 1
62 %invar.cond = icmp eq i16 %lv, 0
63 br i1 %invar.cond, label %noclobber, label %loop.latch
69 %iv.next = add i32 %iv, 1
70 %ec = icmp eq i32 %iv, 1000
71 br i1 %ec, label %exit, label %loop