1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; Test to make sure that a new block is inserted if we
3 ; have more than 2 predecessors for the block we're going to sink to.
4 ; RUN: opt -passes=mldst-motion -S < %s | FileCheck %s --check-prefix=CHECK-NO
5 ; RUN: opt -debug-pass-manager -aa-pipeline=basic-aa -passes='require<memdep>,mldst-motion' -S < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-NO,CHECK-INV-NO
6 ; RUN: opt -debug-pass-manager -aa-pipeline=basic-aa -passes='require<memdep>,mldst-motion<split-footer-bb>' -S < %s 2>&1 | FileCheck %s --check-prefixes=CHECK-YES,CHECK-INV-YES
7 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
9 ; When passing split-footer-bb to MLSM, it invalidates CFG analyses
10 ; CHECK-INV-NO: Running pass: MergedLoadStoreMotionPass
11 ; CHECK-INV-NO-NOT: Invalidating analysis: DominatorTreeAnalysis
12 ; CHECK-INV-YES: Running pass: MergedLoadStoreMotionPass
13 ; CHECK-INV-YES: Invalidating analysis: DominatorTreeAnalysis
15 ; Function Attrs: nounwind uwtable
16 define dso_local void @st_sink_split_bb(ptr nocapture %arg, ptr nocapture %arg1, i1 zeroext %arg2, i1 zeroext %arg3) local_unnamed_addr {
17 ; CHECK-NO-LABEL: @st_sink_split_bb(
19 ; CHECK-NO-NEXT: br i1 [[ARG2:%.*]], label [[BB4:%.*]], label [[BB5:%.*]]
21 ; CHECK-NO-NEXT: store i32 1, ptr [[ARG:%.*]], align 4
22 ; CHECK-NO-NEXT: br label [[BB9:%.*]]
24 ; CHECK-NO-NEXT: br i1 [[ARG3:%.*]], label [[BB6:%.*]], label [[BB7:%.*]]
26 ; CHECK-NO-NEXT: store i32 2, ptr [[ARG]], align 4
27 ; CHECK-NO-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, ptr [[ARG1:%.*]], i64 1
28 ; CHECK-NO-NEXT: store i32 3, ptr [[TMP1]], align 4
29 ; CHECK-NO-NEXT: [[TMP:%.*]] = getelementptr inbounds i32, ptr [[ARG1]], i64 2
30 ; CHECK-NO-NEXT: store i32 3, ptr [[TMP]], align 4
31 ; CHECK-NO-NEXT: br label [[BB9]]
33 ; CHECK-NO-NEXT: store i32 3, ptr [[ARG]], align 4
34 ; CHECK-NO-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, ptr [[ARG1]], i64 1
35 ; CHECK-NO-NEXT: store i32 3, ptr [[TMP2]], align 4
36 ; CHECK-NO-NEXT: [[TMP8:%.*]] = getelementptr inbounds i32, ptr [[ARG1]], i64 2
37 ; CHECK-NO-NEXT: store i32 3, ptr [[TMP8]], align 4
38 ; CHECK-NO-NEXT: br label [[BB9]]
40 ; CHECK-NO-NEXT: ret void
42 ; CHECK-YES-LABEL: @st_sink_split_bb(
44 ; CHECK-YES-NEXT: br i1 [[ARG2:%.*]], label [[BB4:%.*]], label [[BB5:%.*]]
46 ; CHECK-YES-NEXT: store i32 1, ptr [[ARG:%.*]], align 4
47 ; CHECK-YES-NEXT: br label [[BB9:%.*]]
49 ; CHECK-YES-NEXT: br i1 [[ARG3:%.*]], label [[BB6:%.*]], label [[BB7:%.*]]
51 ; CHECK-YES-NEXT: br label [[BB9_SINK_SPLIT:%.*]]
53 ; CHECK-YES-NEXT: br label [[BB9_SINK_SPLIT]]
54 ; CHECK-YES: bb9.sink.split:
55 ; CHECK-YES-NEXT: [[DOTSINK:%.*]] = phi i32 [ 2, [[BB6]] ], [ 3, [[BB7]] ]
56 ; CHECK-YES-NEXT: store i32 [[DOTSINK]], ptr [[ARG]], align 4
57 ; CHECK-YES-NEXT: [[TMP0:%.*]] = getelementptr inbounds i32, ptr [[ARG1:%.*]], i64 1
58 ; CHECK-YES-NEXT: store i32 3, ptr [[TMP0]], align 4
59 ; CHECK-YES-NEXT: [[TMP1:%.*]] = getelementptr inbounds i32, ptr [[ARG1]], i64 2
60 ; CHECK-YES-NEXT: store i32 3, ptr [[TMP1]], align 4
61 ; CHECK-YES-NEXT: br label [[BB9]]
63 ; CHECK-YES-NEXT: ret void
66 br i1 %arg2, label %bb4, label %bb5
69 store i32 1, ptr %arg, align 4
73 br i1 %arg3, label %bb6, label %bb7
76 store i32 2, ptr %arg, align 4
77 %tmp1 = getelementptr inbounds i32, ptr %arg1, i64 1
78 store i32 3, ptr %tmp1, align 4
79 %tmp = getelementptr inbounds i32, ptr %arg1, i64 2
80 store i32 3, ptr %tmp, align 4
84 store i32 3, ptr %arg, align 4
85 %tmp2 = getelementptr inbounds i32, ptr %arg1, i64 1
86 store i32 3, ptr %tmp2, align 4
87 %tmp8 = getelementptr inbounds i32, ptr %arg1, i64 2
88 store i32 3, ptr %tmp8, align 4
92 bb9: ; preds = %bb7, %bb6, %bb4