1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
3 ; RUN: opt < %s -passes=dse -S | FileCheck --check-prefix=NO-LIMIT %s
4 ; RUN: opt < %s -passes=dse -dse-memoryssa-scanlimit=0 -S | FileCheck --check-prefix=LIMIT-0 %s
5 ; RUN: opt < %s -passes=dse -dse-memoryssa-scanlimit=2 -S | FileCheck --check-prefix=LIMIT-2 %s
6 ; RUN: opt < %s -passes=dse -dse-memoryssa-scanlimit=3 -S | FileCheck --check-prefix=LIMIT-3 %s
7 ; RUN: opt < %s -passes=dse -dse-memoryssa-scanlimit=4 -S | FileCheck --check-prefix=LIMIT-4 %s
9 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
12 define void @test2(ptr noalias %P, ptr noalias %Q, ptr noalias %R) {
13 ; NO-LIMIT-LABEL: @test2(
14 ; NO-LIMIT-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
16 ; NO-LIMIT-NEXT: br label [[BB3:%.*]]
18 ; NO-LIMIT-NEXT: br label [[BB3]]
20 ; NO-LIMIT-NEXT: store i32 0, ptr [[Q:%.*]], align 4
21 ; NO-LIMIT-NEXT: store i32 0, ptr [[R:%.*]], align 4
22 ; NO-LIMIT-NEXT: store i32 0, ptr [[P:%.*]], align 4
23 ; NO-LIMIT-NEXT: ret void
25 ; LIMIT-0-LABEL: @test2(
26 ; LIMIT-0-NEXT: store i32 1, ptr [[P:%.*]], align 4
27 ; LIMIT-0-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
29 ; LIMIT-0-NEXT: br label [[BB3:%.*]]
31 ; LIMIT-0-NEXT: br label [[BB3]]
33 ; LIMIT-0-NEXT: store i32 0, ptr [[Q:%.*]], align 4
34 ; LIMIT-0-NEXT: store i32 0, ptr [[R:%.*]], align 4
35 ; LIMIT-0-NEXT: store i32 0, ptr [[P]], align 4
36 ; LIMIT-0-NEXT: ret void
38 ; LIMIT-2-LABEL: @test2(
39 ; LIMIT-2-NEXT: store i32 1, ptr [[P:%.*]], align 4
40 ; LIMIT-2-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
42 ; LIMIT-2-NEXT: br label [[BB3:%.*]]
44 ; LIMIT-2-NEXT: br label [[BB3]]
46 ; LIMIT-2-NEXT: store i32 0, ptr [[Q:%.*]], align 4
47 ; LIMIT-2-NEXT: store i32 0, ptr [[R:%.*]], align 4
48 ; LIMIT-2-NEXT: store i32 0, ptr [[P]], align 4
49 ; LIMIT-2-NEXT: ret void
51 ; LIMIT-3-LABEL: @test2(
52 ; LIMIT-3-NEXT: br i1 true, label [[BB1:%.*]], label [[BB2:%.*]]
54 ; LIMIT-3-NEXT: br label [[BB3:%.*]]
56 ; LIMIT-3-NEXT: br label [[BB3]]
58 ; LIMIT-3-NEXT: store i32 0, ptr [[Q:%.*]], align 4
59 ; LIMIT-3-NEXT: store i32 0, ptr [[R:%.*]], align 4
60 ; LIMIT-3-NEXT: store i32 0, ptr [[P:%.*]], align 4
61 ; LIMIT-3-NEXT: ret void
64 br i1 true, label %bb1, label %bb2
76 define void @duplicate_worklist_endoffunction(ptr %ptr.0, ptr %ptr.1) {
77 ; LIMIT-4-LABEL: @duplicate_worklist_endoffunction(
78 ; LIMIT-4-NEXT: entry:
79 ; LIMIT-4-NEXT: [[STACK_0:%.*]] = alloca [768 x i8], align 16
80 ; LIMIT-4-NEXT: [[VAL_0:%.*]] = load i16, ptr [[PTR_1:%.*]], align 8
81 ; LIMIT-4-NEXT: [[COND:%.*]] = icmp ugt i16 [[VAL_0]], 24
82 ; LIMIT-4-NEXT: br i1 [[COND]], label [[BB_1:%.*]], label [[EXIT:%.*]]
84 ; LIMIT-4-NEXT: br label [[LOOP:%.*]]
86 ; LIMIT-4-NEXT: [[IV:%.*]] = phi i64 [ 0, [[BB_1]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
87 ; LIMIT-4-NEXT: [[PTR_3:%.*]] = getelementptr i8, ptr [[STACK_0]], i64 [[IV]]
88 ; LIMIT-4-NEXT: store ptr [[PTR_0:%.*]], ptr [[PTR_3]], align 2
89 ; LIMIT-4-NEXT: [[IV_NEXT]] = add nuw i64 [[IV]], 1
90 ; LIMIT-4-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], 10
91 ; LIMIT-4-NEXT: br i1 [[EXITCOND]], label [[EXIT]], label [[LOOP]]
93 ; LIMIT-4-NEXT: ret void
96 %stack.0 = alloca [768 x i8], align 16
97 %stack.1 = alloca [20 x i8], align 8
98 %val.0 = load i16, ptr %ptr.1, align 8
99 %cond = icmp ugt i16 %val.0, 24
100 br i1 %cond, label %bb.1, label %exit
102 bb.1: ; preds = %entry
103 %ptr.2 = getelementptr inbounds i8, ptr %ptr.1, i64 8
104 %val.1 = load i64, ptr %ptr.2, align 8
105 store i64 %val.1, ptr %stack.1, align 8
108 loop: ; preds = %loop, %bb.1
109 %iv = phi i64 [ 0, %bb.1 ], [ %iv.next, %loop ]
110 %ptr.3 = getelementptr i8, ptr %stack.0, i64 %iv
111 store ptr %ptr.0, ptr %ptr.3, align 2
112 %iv.next = add nuw i64 %iv, 1
113 %exitcond = icmp eq i64 %iv.next, 10
114 br i1 %exitcond, label %exit, label %loop
116 exit: ; preds = %loop, %entry