1 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 -verify-machineinstrs | FileCheck %s
3 @CVal = external local_unnamed_addr global i8, align 1
4 @SVal = external local_unnamed_addr global i16, align 2
5 @IVal = external local_unnamed_addr global i32, align 4
6 @LVal = external local_unnamed_addr global i64, align 8
7 @USVal = external local_unnamed_addr global i16, align 2
8 @arr = external local_unnamed_addr global i64*, align 8
9 @arri = external local_unnamed_addr global i32*, align 8
11 ; Test the same constant can be used by different stores.
13 %struct.S = type { i64, i8, i16, i32 }
15 define void @foo(%struct.S* %p) {
16 %l4 = bitcast %struct.S* %p to i64*
17 store i64 0, i64* %l4, align 8
18 %c = getelementptr %struct.S, %struct.S* %p, i64 0, i32 1
19 store i8 0, i8* %c, align 8
20 %s = getelementptr %struct.S, %struct.S* %p, i64 0, i32 2
21 store i16 0, i16* %s, align 2
22 %i = getelementptr %struct.S, %struct.S* %p, i64 0, i32 3
23 store i32 0, i32* %i, align 4
34 define void @bar(%struct.S* %p) {
35 %i = getelementptr %struct.S, %struct.S* %p, i64 0, i32 3
36 store i32 2, i32* %i, align 4
37 %s = getelementptr %struct.S, %struct.S* %p, i64 0, i32 2
38 store i16 2, i16* %s, align 2
39 %c = getelementptr %struct.S, %struct.S* %p, i64 0, i32 1
40 store i8 2, i8* %c, align 8
41 %l4 = bitcast %struct.S* %p to i64*
42 store i64 2, i64* %l4, align 8
47 ; CHECK-DAG: stw 4, 12(3)
48 ; CHECK-DAG: sth 4, 10(3)
49 ; CHECK-DAG: std 4, 0(3)
50 ; CHECK-DAG: stb 4, 8(3)
53 ; Function Attrs: norecurse nounwind
54 define void @setSmallNeg() {
56 store i8 -7, i8* @CVal, align 1
57 store i16 -7, i16* @SVal, align 2
58 store i32 -7, i32* @IVal, align 4
59 store i64 -7, i64* @LVal, align 8
61 ; CHECK-LABEL: setSmallNeg
69 ; Function Attrs: norecurse nounwind
70 define void @setSmallPos() {
72 store i8 8, i8* @CVal, align 1
73 store i16 8, i16* @SVal, align 2
74 store i32 8, i32* @IVal, align 4
75 store i64 8, i64* @LVal, align 8
77 ; CHECK-LABEL: setSmallPos
85 ; Function Attrs: norecurse nounwind
86 define void @setMaxNeg() {
88 store i16 -32768, i16* @SVal, align 2
89 store i32 -32768, i32* @IVal, align 4
90 store i64 -32768, i64* @LVal, align 8
92 ; CHECK-LABEL: setMaxNeg
99 ; Function Attrs: norecurse nounwind
100 define void @setMaxPos() {
102 store i16 32767, i16* @SVal, align 2
103 store i32 32767, i32* @IVal, align 4
104 store i64 32767, i64* @LVal, align 8
106 ; CHECK-LABEL: setMaxPos
113 ; Function Attrs: norecurse nounwind
114 define void @setExcessiveNeg() {
116 store i32 -32769, i32* @IVal, align 4
117 store i64 -32769, i64* @LVal, align 8
119 ; CHECK-LABEL: setExcessiveNeg
121 ; CHECK: ori 5, 5, 32767
126 ; Function Attrs: norecurse nounwind
127 define void @setExcessivePos() {
129 store i16 -32768, i16* @USVal, align 2
130 store i32 32768, i32* @IVal, align 4
131 store i64 32768, i64* @LVal, align 8
133 ; CHECK-LABEL: setExcessivePos
135 ; CHECK: ori 6, 6, 32768
141 define void @SetArr(i32 signext %Len) {
143 %cmp7 = icmp sgt i32 %Len, 0
144 br i1 %cmp7, label %for.body.lr.ph, label %for.cond.cleanup
146 for.body.lr.ph: ; preds = %entry
147 %0 = load i64*, i64** @arr, align 8
148 %1 = load i32*, i32** @arri, align 8
149 %wide.trip.count = zext i32 %Len to i64
152 for.cond.cleanup: ; preds = %for.body, %entry
155 for.body: ; preds = %for.body, %for.body.lr.ph
156 %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
157 %arrayidx = getelementptr inbounds i64, i64* %0, i64 %indvars.iv
158 store i64 -7, i64* %arrayidx, align 8
159 %arrayidx2 = getelementptr inbounds i32, i32* %1, i64 %indvars.iv
160 store i32 -7, i32* %arrayidx2, align 4
161 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
162 %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count
163 br i1 %exitcond, label %for.cond.cleanup, label %for.body
164 ; CHECK-LABEL: SetArr
166 ; CHECK: stdu 5, 8(3)
167 ; CHECK: stwu 5, 4(4)
170 define void @setSameValDiffSizeCI() {
172 store i32 255, i32* @IVal, align 4
173 store i8 -1, i8* @CVal, align 1
175 ; CHECK-LABEL: setSameValDiffSizeCI
181 define void @setSameValDiffSizeSI() {
183 store i32 65535, i32* @IVal, align 4
184 store i16 -1, i16* @SVal, align 2
186 ; CHECK-LABEL: setSameValDiffSizeSI
188 ; CHECK: ori 5, 5, 65535