1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basic-aa -dse -S | FileCheck %s
4 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
6 define void @second_store_smaller_1(i32* noalias %P, i1 %c) {
7 ; CHECK-LABEL: @second_store_smaller_1(
8 ; CHECK-NEXT: store i32 0, i32* [[P:%.*]], align 4
9 ; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
11 ; CHECK-NEXT: br label [[BB3:%.*]]
13 ; CHECK-NEXT: br label [[BB3]]
15 ; CHECK-NEXT: ret void
18 br i1 %c, label %bb1, label %bb2
24 %P.i16 = bitcast i32* %P to i16*
25 store i16 0, i16* %P.i16
29 define void @second_store_smaller_2(i32* noalias %P, i1 %c) {
30 ; CHECK-LABEL: @second_store_smaller_2(
31 ; CHECK-NEXT: store i32 12345, i32* [[P:%.*]], align 4
32 ; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
34 ; CHECK-NEXT: br label [[BB3:%.*]]
36 ; CHECK-NEXT: br label [[BB3]]
38 ; CHECK-NEXT: ret void
41 br i1 %c, label %bb1, label %bb2
47 %P.i16 = bitcast i32* %P to i16*
48 store i16 12345, i16* %P.i16
52 declare void @use(i16) readnone
53 declare void @use.i8(i8) readnone
55 define void @second_store_smaller_3(i32* noalias %P, i1 %c) {
56 ; CHECK-LABEL: @second_store_smaller_3(
57 ; CHECK-NEXT: store i32 1, i32* [[P:%.*]], align 4
58 ; CHECK-NEXT: [[P_I16:%.*]] = bitcast i32* [[P]] to i16*
59 ; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
61 ; CHECK-NEXT: [[L1:%.*]] = load i16, i16* [[P_I16]], align 2
62 ; CHECK-NEXT: call void @use(i16 [[L1]])
63 ; CHECK-NEXT: br label [[BB3:%.*]]
65 ; CHECK-NEXT: br label [[BB3]]
67 ; CHECK-NEXT: store i16 -31073, i16* [[P_I16]], align 2
68 ; CHECK-NEXT: ret void
71 %P.i16 = bitcast i32* %P to i16*
72 br i1 %c, label %bb1, label %bb2
75 %l1 = load i16, i16* %P.i16
76 call void @use(i16 %l1)
81 store i16 -31073, i16* %P.i16
85 define void @second_store_smaller_4(i32* noalias %P, i1 %c) {
86 ; CHECK-LABEL: @second_store_smaller_4(
87 ; CHECK-NEXT: store i32 1, i32* [[P:%.*]], align 4
88 ; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
90 ; CHECK-NEXT: [[P_I8:%.*]] = bitcast i32* [[P]] to i8*
91 ; CHECK-NEXT: [[L1:%.*]] = load i8, i8* [[P_I8]], align 1
92 ; CHECK-NEXT: call void @use.i8(i8 [[L1]])
93 ; CHECK-NEXT: br label [[BB3:%.*]]
95 ; CHECK-NEXT: br label [[BB3]]
97 ; CHECK-NEXT: [[P_I16:%.*]] = bitcast i32* [[P]] to i16*
98 ; CHECK-NEXT: store i16 -31073, i16* [[P_I16]], align 2
99 ; CHECK-NEXT: ret void
102 br i1 %c, label %bb1, label %bb2
105 %P.i8 = bitcast i32* %P to i8*
106 %l1 = load i8, i8* %P.i8
107 call void @use.i8(i8 %l1)
112 %P.i16 = bitcast i32* %P to i16*
113 store i16 -31073, i16* %P.i16
117 define void @second_store_smaller_5(i32* noalias %P, i16 %x, i1 %c) {
118 ; CHECK-LABEL: @second_store_smaller_5(
119 ; CHECK-NEXT: store i32 1, i32* [[P:%.*]], align 4
120 ; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
122 ; CHECK-NEXT: br label [[BB3:%.*]]
124 ; CHECK-NEXT: br label [[BB3]]
126 ; CHECK-NEXT: [[P_I16:%.*]] = bitcast i32* [[P]] to i16*
127 ; CHECK-NEXT: store i16 [[X:%.*]], i16* [[P_I16]], align 2
128 ; CHECK-NEXT: ret void
131 br i1 %c, label %bb1, label %bb2
137 %P.i16 = bitcast i32* %P to i16*
138 store i16 %x, i16* %P.i16
142 define void @second_store_bigger(i32* noalias %P, i1 %c) {
143 ; CHECK-LABEL: @second_store_bigger(
144 ; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
146 ; CHECK-NEXT: br label [[BB3:%.*]]
148 ; CHECK-NEXT: br label [[BB3]]
150 ; CHECK-NEXT: [[P_I64:%.*]] = bitcast i32* [[P:%.*]] to i64*
151 ; CHECK-NEXT: store i64 0, i64* [[P_I64]], align 8
152 ; CHECK-NEXT: ret void
155 br i1 %c, label %bb1, label %bb2
161 %P.i64 = bitcast i32* %P to i64*
162 store i64 0, i64* %P.i64