1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=mldst-motion -S < %s | FileCheck %s
3 ;target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
5 define void @no_gep_same_ptr(i1 %c, ptr %p, i32 %x, i32 %y) {
6 ; CHECK-LABEL: @no_gep_same_ptr(
8 ; CHECK-NEXT: br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
10 ; CHECK-NEXT: br label [[IF_END:%.*]]
12 ; CHECK-NEXT: br label [[IF_END]]
14 ; CHECK-NEXT: [[Y_SINK:%.*]] = phi i32 [ [[X:%.*]], [[IF_THEN]] ], [ [[Y:%.*]], [[IF_ELSE]] ]
15 ; CHECK-NEXT: store i32 [[Y_SINK]], ptr [[P:%.*]], align 4
16 ; CHECK-NEXT: ret void
19 br i1 %c, label %if.then, label %if.else
33 define void @no_gep_different_ptr(i1 %c, ptr %p1, ptr %p2, i32 %x, i32 %y) {
34 ; CHECK-LABEL: @no_gep_different_ptr(
36 ; CHECK-NEXT: br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
38 ; CHECK-NEXT: store i32 [[X:%.*]], ptr [[P1:%.*]], align 4
39 ; CHECK-NEXT: br label [[IF_END:%.*]]
41 ; CHECK-NEXT: store i32 [[Y:%.*]], ptr [[P2:%.*]], align 4
42 ; CHECK-NEXT: br label [[IF_END]]
44 ; CHECK-NEXT: ret void
47 br i1 %c, label %if.then, label %if.else
61 define void @shared_gep(i1 %c, ptr %p, i32 %x, i32 %y) {
62 ; CHECK-LABEL: @shared_gep(
64 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i32, ptr [[P:%.*]], i32 1
65 ; CHECK-NEXT: br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
67 ; CHECK-NEXT: br label [[IF_END:%.*]]
69 ; CHECK-NEXT: br label [[IF_END]]
71 ; CHECK-NEXT: [[Y_SINK:%.*]] = phi i32 [ [[X:%.*]], [[IF_THEN]] ], [ [[Y:%.*]], [[IF_ELSE]] ]
72 ; CHECK-NEXT: store i32 [[Y_SINK]], ptr [[GEP]], align 4
73 ; CHECK-NEXT: ret void
76 %gep = getelementptr i32, ptr %p, i32 1
77 br i1 %c, label %if.then, label %if.else
80 store i32 %x, ptr %gep
84 store i32 %y, ptr %gep
91 define void @separate_geps(i1 %c, ptr %p, i32 %x, i32 %y) {
92 ; CHECK-LABEL: @separate_geps(
94 ; CHECK-NEXT: br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
96 ; CHECK-NEXT: br label [[IF_END:%.*]]
98 ; CHECK-NEXT: br label [[IF_END]]
100 ; CHECK-NEXT: [[Y_SINK:%.*]] = phi i32 [ [[X:%.*]], [[IF_THEN]] ], [ [[Y:%.*]], [[IF_ELSE]] ]
101 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i32, ptr [[P:%.*]], i32 1
102 ; CHECK-NEXT: store i32 [[Y_SINK]], ptr [[TMP0]], align 4
103 ; CHECK-NEXT: ret void
106 br i1 %c, label %if.then, label %if.else
109 %gep1 = getelementptr i32, ptr %p, i32 1
110 store i32 %x, ptr %gep1
114 %gep2 = getelementptr i32, ptr %p, i32 1
115 store i32 %y, ptr %gep2