xref: /aosp_15_r20/external/llvm/test/CodeGen/PowerPC/peephole-align.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -mcpu=pwr7 -O1 -code-model=medium <%s | FileCheck -check-prefix=POWER7 -check-prefix=CHECK %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -mcpu=pwr8 -O1 -code-model=medium <%s | FileCheck -check-prefix=POWER8 -check-prefix=CHECK %s
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker; Test peephole optimization for medium code model (32-bit TOC offsets)
5*9880d681SAndroid Build Coastguard Worker; for loading and storing small offsets within aligned values.
6*9880d681SAndroid Build Coastguard Worker; For power8, verify that the optimization doesn't fire, as it prevents fusion
7*9880d681SAndroid Build Coastguard Worker; opportunities.
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Workertarget datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
10*9880d681SAndroid Build Coastguard Workertarget triple = "powerpc64-unknown-linux-gnu"
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker%struct.b4 = type<{ i8, i8, i8, i8 }>
13*9880d681SAndroid Build Coastguard Worker%struct.h2 = type<{ i16, i16 }>
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Worker%struct.b8 = type<{ i8, i8, i8, i8, i8, i8, i8, i8 }>
16*9880d681SAndroid Build Coastguard Worker%struct.h4 = type<{ i16, i16, i16, i16 }>
17*9880d681SAndroid Build Coastguard Worker%struct.w2 = type<{ i32, i32 }>
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker%struct.d2 = type<{ i64, i64 }>
20*9880d681SAndroid Build Coastguard Worker%struct.misalign = type<{ i8, i64 }>
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker@b4v = global %struct.b4 <{ i8 1, i8 2, i8 3, i8 4 }>, align 4
23*9880d681SAndroid Build Coastguard Worker@h2v = global %struct.h2 <{ i16 1, i16 2 }>, align 4
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker@b8v = global %struct.b8 <{ i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8 }>, align 8
26*9880d681SAndroid Build Coastguard Worker@h4v = global %struct.h4 <{ i16 1, i16 2, i16 3, i16 4 }>, align 8
27*9880d681SAndroid Build Coastguard Worker@w2v = global %struct.w2 <{ i32 1, i32 2 }>, align 8
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker@d2v = global %struct.d2 <{ i64 1, i64 2 }>, align 16
30*9880d681SAndroid Build Coastguard Worker@misalign_v = global %struct.misalign <{ i8 1, i64 2 }>, align 16
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_b4:
33*9880d681SAndroid Build Coastguard Worker; POWER7: addis [[REGSTRUCT:[0-9]+]], 2, b4v@toc@ha
34*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG0_0:[0-9]+]], b4v@toc@l([[REGSTRUCT]])
35*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG1_0:[0-9]+]], b4v@toc@l+1([[REGSTRUCT]])
36*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG2_0:[0-9]+]], b4v@toc@l+2([[REGSTRUCT]])
37*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG3_0:[0-9]+]], b4v@toc@l+3([[REGSTRUCT]])
38*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
39*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
40*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG2_1:[0-9]+]], [[REG2_0]], 3
41*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG3_1:[0-9]+]], [[REG3_0]], 4
42*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG0_1]], b4v@toc@l([[REGSTRUCT]])
43*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG1_1]], b4v@toc@l+1([[REGSTRUCT]])
44*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG2_1]], b4v@toc@l+2([[REGSTRUCT]])
45*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG3_1]], b4v@toc@l+3([[REGSTRUCT]])
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Worker; POWER8: addis [[REGSTRUCT:[0-9]+]], 2, b4v@toc@ha
48*9880d681SAndroid Build Coastguard Worker; POWER8-NEXT: addi [[REGSTRUCT]], [[REGSTRUCT]], b4v@toc@l
49*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG0_0:[0-9]+]], 0([[REGSTRUCT]])
50*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG1_0:[0-9]+]], 1([[REGSTRUCT]])
51*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG2_0:[0-9]+]], 2([[REGSTRUCT]])
52*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG3_0:[0-9]+]], 3([[REGSTRUCT]])
53*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
54*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
55*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG2_1:[0-9]+]], [[REG2_0]], 3
56*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG3_1:[0-9]+]], [[REG3_0]], 4
57*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG0_1]], 0([[REGSTRUCT]])
58*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG1_1]], 1([[REGSTRUCT]])
59*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG2_1]], 2([[REGSTRUCT]])
60*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG3_1]], 3([[REGSTRUCT]])
61*9880d681SAndroid Build Coastguard Workerdefine void @test_b4() nounwind {
62*9880d681SAndroid Build Coastguard Workerentry:
63*9880d681SAndroid Build Coastguard Worker  %0 = load i8, i8* getelementptr inbounds (%struct.b4, %struct.b4* @b4v, i32 0, i32 0), align 1
64*9880d681SAndroid Build Coastguard Worker  %inc0 = add nsw i8 %0, 1
65*9880d681SAndroid Build Coastguard Worker  store i8 %inc0, i8* getelementptr inbounds (%struct.b4, %struct.b4* @b4v, i32 0, i32 0), align 1
66*9880d681SAndroid Build Coastguard Worker  %1 = load i8, i8* getelementptr inbounds (%struct.b4, %struct.b4* @b4v, i32 0, i32 1), align 1
67*9880d681SAndroid Build Coastguard Worker  %inc1 = add nsw i8 %1, 2
68*9880d681SAndroid Build Coastguard Worker  store i8 %inc1, i8* getelementptr inbounds (%struct.b4, %struct.b4* @b4v, i32 0, i32 1), align 1
69*9880d681SAndroid Build Coastguard Worker  %2 = load i8, i8* getelementptr inbounds (%struct.b4, %struct.b4* @b4v, i32 0, i32 2), align 1
70*9880d681SAndroid Build Coastguard Worker  %inc2 = add nsw i8 %2, 3
71*9880d681SAndroid Build Coastguard Worker  store i8 %inc2, i8* getelementptr inbounds (%struct.b4, %struct.b4* @b4v, i32 0, i32 2), align 1
72*9880d681SAndroid Build Coastguard Worker  %3 = load i8, i8* getelementptr inbounds (%struct.b4, %struct.b4* @b4v, i32 0, i32 3), align 1
73*9880d681SAndroid Build Coastguard Worker  %inc3 = add nsw i8 %3, 4
74*9880d681SAndroid Build Coastguard Worker  store i8 %inc3, i8* getelementptr inbounds (%struct.b4, %struct.b4* @b4v, i32 0, i32 3), align 1
75*9880d681SAndroid Build Coastguard Worker  ret void
76*9880d681SAndroid Build Coastguard Worker}
77*9880d681SAndroid Build Coastguard Worker
78*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_h2:
79*9880d681SAndroid Build Coastguard Worker; POWER7: addis [[REGSTRUCT:[0-9]+]], 2, h2v@toc@ha
80*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lhz [[REG0_0:[0-9]+]], h2v@toc@l([[REGSTRUCT]])
81*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lhz [[REG1_0:[0-9]+]], h2v@toc@l+2([[REGSTRUCT]])
82*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
83*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
84*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: sth [[REG0_1]], h2v@toc@l([[REGSTRUCT]])
85*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: sth [[REG1_1]], h2v@toc@l+2([[REGSTRUCT]])
86*9880d681SAndroid Build Coastguard Worker
87*9880d681SAndroid Build Coastguard Worker; POWER8: addis [[REGSTRUCT:[0-9]+]], 2, h2v@toc@ha
88*9880d681SAndroid Build Coastguard Worker; POWER8-NEXT: addi [[REGSTRUCT]], [[REGSTRUCT]], h2v@toc@l
89*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lhz [[REG0_0:[0-9]+]], 0([[REGSTRUCT]])
90*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lhz [[REG1_0:[0-9]+]], 2([[REGSTRUCT]])
91*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
92*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
93*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: sth [[REG0_1]], 0([[REGSTRUCT]])
94*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: sth [[REG1_1]], 2([[REGSTRUCT]])
95*9880d681SAndroid Build Coastguard Workerdefine void @test_h2() nounwind {
96*9880d681SAndroid Build Coastguard Workerentry:
97*9880d681SAndroid Build Coastguard Worker  %0 = load i16, i16* getelementptr inbounds (%struct.h2, %struct.h2* @h2v, i32 0, i32 0), align 2
98*9880d681SAndroid Build Coastguard Worker  %inc0 = add nsw i16 %0, 1
99*9880d681SAndroid Build Coastguard Worker  store i16 %inc0, i16* getelementptr inbounds (%struct.h2, %struct.h2* @h2v, i32 0, i32 0), align 2
100*9880d681SAndroid Build Coastguard Worker  %1 = load i16, i16* getelementptr inbounds (%struct.h2, %struct.h2* @h2v, i32 0, i32 1), align 2
101*9880d681SAndroid Build Coastguard Worker  %inc1 = add nsw i16 %1, 2
102*9880d681SAndroid Build Coastguard Worker  store i16 %inc1, i16* getelementptr inbounds (%struct.h2, %struct.h2* @h2v, i32 0, i32 1), align 2
103*9880d681SAndroid Build Coastguard Worker  ret void
104*9880d681SAndroid Build Coastguard Worker}
105*9880d681SAndroid Build Coastguard Worker
106*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_h2_optsize:
107*9880d681SAndroid Build Coastguard Worker; CHECK: addis [[REGSTRUCT:[0-9]+]], 2, h2v@toc@ha
108*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: lhz [[REG0_0:[0-9]+]], h2v@toc@l([[REGSTRUCT]])
109*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: lhz [[REG1_0:[0-9]+]], h2v@toc@l+2([[REGSTRUCT]])
110*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
111*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
112*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: sth [[REG0_1]], h2v@toc@l([[REGSTRUCT]])
113*9880d681SAndroid Build Coastguard Worker; CHECK-DAG: sth [[REG1_1]], h2v@toc@l+2([[REGSTRUCT]])
114*9880d681SAndroid Build Coastguard Workerdefine void @test_h2_optsize() optsize nounwind {
115*9880d681SAndroid Build Coastguard Workerentry:
116*9880d681SAndroid Build Coastguard Worker  %0 = load i16, i16* getelementptr inbounds (%struct.h2, %struct.h2* @h2v, i32 0, i32 0), align 2
117*9880d681SAndroid Build Coastguard Worker  %inc0 = add nsw i16 %0, 1
118*9880d681SAndroid Build Coastguard Worker  store i16 %inc0, i16* getelementptr inbounds (%struct.h2, %struct.h2* @h2v, i32 0, i32 0), align 2
119*9880d681SAndroid Build Coastguard Worker  %1 = load i16, i16* getelementptr inbounds (%struct.h2, %struct.h2* @h2v, i32 0, i32 1), align 2
120*9880d681SAndroid Build Coastguard Worker  %inc1 = add nsw i16 %1, 2
121*9880d681SAndroid Build Coastguard Worker  store i16 %inc1, i16* getelementptr inbounds (%struct.h2, %struct.h2* @h2v, i32 0, i32 1), align 2
122*9880d681SAndroid Build Coastguard Worker  ret void
123*9880d681SAndroid Build Coastguard Worker}
124*9880d681SAndroid Build Coastguard Worker
125*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_b8:
126*9880d681SAndroid Build Coastguard Worker; POWER7: addis [[REGSTRUCT:[0-9]+]], 2, b8v@toc@ha
127*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG0_0:[0-9]+]], b8v@toc@l([[REGSTRUCT]])
128*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG1_0:[0-9]+]], b8v@toc@l+1([[REGSTRUCT]])
129*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG2_0:[0-9]+]], b8v@toc@l+2([[REGSTRUCT]])
130*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG3_0:[0-9]+]], b8v@toc@l+3([[REGSTRUCT]])
131*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG4_0:[0-9]+]], b8v@toc@l+4([[REGSTRUCT]])
132*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG5_0:[0-9]+]], b8v@toc@l+5([[REGSTRUCT]])
133*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG6_0:[0-9]+]], b8v@toc@l+6([[REGSTRUCT]])
134*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lbz [[REG7_0:[0-9]+]], b8v@toc@l+7([[REGSTRUCT]])
135*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
136*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
137*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG2_1:[0-9]+]], [[REG2_0]], 3
138*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG3_1:[0-9]+]], [[REG3_0]], 4
139*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG4_1:[0-9]+]], [[REG4_0]], 5
140*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG5_1:[0-9]+]], [[REG5_0]], 6
141*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG6_1:[0-9]+]], [[REG6_0]], 7
142*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG7_1:[0-9]+]], [[REG7_0]], 8
143*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG0_1]], b8v@toc@l([[REGSTRUCT]])
144*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG1_1]], b8v@toc@l+1([[REGSTRUCT]])
145*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG2_1]], b8v@toc@l+2([[REGSTRUCT]])
146*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG3_1]], b8v@toc@l+3([[REGSTRUCT]])
147*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG4_1]], b8v@toc@l+4([[REGSTRUCT]])
148*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG5_1]], b8v@toc@l+5([[REGSTRUCT]])
149*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG6_1]], b8v@toc@l+6([[REGSTRUCT]])
150*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stb [[REG7_1]], b8v@toc@l+7([[REGSTRUCT]])
151*9880d681SAndroid Build Coastguard Worker
152*9880d681SAndroid Build Coastguard Worker; POWER8: addis [[REGSTRUCT:[0-9]+]], 2, b8v@toc@ha
153*9880d681SAndroid Build Coastguard Worker; POWER8-NEXT: addi [[REGSTRUCT]], [[REGSTRUCT]], b8v@toc@l
154*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG0_0:[0-9]+]], 0([[REGSTRUCT]])
155*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG1_0:[0-9]+]], 1([[REGSTRUCT]])
156*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG2_0:[0-9]+]], 2([[REGSTRUCT]])
157*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG3_0:[0-9]+]], 3([[REGSTRUCT]])
158*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG4_0:[0-9]+]], 4([[REGSTRUCT]])
159*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG5_0:[0-9]+]], 5([[REGSTRUCT]])
160*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG6_0:[0-9]+]], 6([[REGSTRUCT]])
161*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lbz [[REG7_0:[0-9]+]], 7([[REGSTRUCT]])
162*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
163*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
164*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG2_1:[0-9]+]], [[REG2_0]], 3
165*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG3_1:[0-9]+]], [[REG3_0]], 4
166*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG4_1:[0-9]+]], [[REG4_0]], 5
167*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG5_1:[0-9]+]], [[REG5_0]], 6
168*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG6_1:[0-9]+]], [[REG6_0]], 7
169*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG7_1:[0-9]+]], [[REG7_0]], 8
170*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG0_1]], 0([[REGSTRUCT]])
171*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG1_1]], 1([[REGSTRUCT]])
172*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG2_1]], 2([[REGSTRUCT]])
173*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG3_1]], 3([[REGSTRUCT]])
174*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG4_1]], 4([[REGSTRUCT]])
175*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG5_1]], 5([[REGSTRUCT]])
176*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG6_1]], 6([[REGSTRUCT]])
177*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stb [[REG7_1]], 7([[REGSTRUCT]])
178*9880d681SAndroid Build Coastguard Workerdefine void @test_b8() nounwind {
179*9880d681SAndroid Build Coastguard Workerentry:
180*9880d681SAndroid Build Coastguard Worker  %0 = load i8, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 0), align 1
181*9880d681SAndroid Build Coastguard Worker  %inc0 = add nsw i8 %0, 1
182*9880d681SAndroid Build Coastguard Worker  store i8 %inc0, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 0), align 1
183*9880d681SAndroid Build Coastguard Worker  %1 = load i8, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 1), align 1
184*9880d681SAndroid Build Coastguard Worker  %inc1 = add nsw i8 %1, 2
185*9880d681SAndroid Build Coastguard Worker  store i8 %inc1, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 1), align 1
186*9880d681SAndroid Build Coastguard Worker  %2 = load i8, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 2), align 1
187*9880d681SAndroid Build Coastguard Worker  %inc2 = add nsw i8 %2, 3
188*9880d681SAndroid Build Coastguard Worker  store i8 %inc2, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 2), align 1
189*9880d681SAndroid Build Coastguard Worker  %3 = load i8, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 3), align 1
190*9880d681SAndroid Build Coastguard Worker  %inc3 = add nsw i8 %3, 4
191*9880d681SAndroid Build Coastguard Worker  store i8 %inc3, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 3), align 1
192*9880d681SAndroid Build Coastguard Worker  %4 = load i8, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 4), align 1
193*9880d681SAndroid Build Coastguard Worker  %inc4 = add nsw i8 %4, 5
194*9880d681SAndroid Build Coastguard Worker  store i8 %inc4, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 4), align 1
195*9880d681SAndroid Build Coastguard Worker  %5 = load i8, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 5), align 1
196*9880d681SAndroid Build Coastguard Worker  %inc5 = add nsw i8 %5, 6
197*9880d681SAndroid Build Coastguard Worker  store i8 %inc5, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 5), align 1
198*9880d681SAndroid Build Coastguard Worker  %6 = load i8, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 6), align 1
199*9880d681SAndroid Build Coastguard Worker  %inc6 = add nsw i8 %6, 7
200*9880d681SAndroid Build Coastguard Worker  store i8 %inc6, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 6), align 1
201*9880d681SAndroid Build Coastguard Worker  %7 = load i8, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 7), align 1
202*9880d681SAndroid Build Coastguard Worker  %inc7 = add nsw i8 %7, 8
203*9880d681SAndroid Build Coastguard Worker  store i8 %inc7, i8* getelementptr inbounds (%struct.b8, %struct.b8* @b8v, i32 0, i32 7), align 1
204*9880d681SAndroid Build Coastguard Worker  ret void
205*9880d681SAndroid Build Coastguard Worker}
206*9880d681SAndroid Build Coastguard Worker
207*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_h4:
208*9880d681SAndroid Build Coastguard Worker; POWER7: addis [[REGSTRUCT:[0-9]+]], 2, h4v@toc@ha
209*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lhz [[REG0_0:[0-9]+]], h4v@toc@l([[REGSTRUCT]])
210*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lhz [[REG1_0:[0-9]+]], h4v@toc@l+2([[REGSTRUCT]])
211*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lhz [[REG2_0:[0-9]+]], h4v@toc@l+4([[REGSTRUCT]])
212*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lhz [[REG3_0:[0-9]+]], h4v@toc@l+6([[REGSTRUCT]])
213*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
214*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
215*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG2_1:[0-9]+]], [[REG2_0]], 3
216*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG3_1:[0-9]+]], [[REG3_0]], 4
217*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: sth [[REG0_1]], h4v@toc@l([[REGSTRUCT]])
218*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: sth [[REG1_1]], h4v@toc@l+2([[REGSTRUCT]])
219*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: sth [[REG2_1]], h4v@toc@l+4([[REGSTRUCT]])
220*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: sth [[REG3_1]], h4v@toc@l+6([[REGSTRUCT]])
221*9880d681SAndroid Build Coastguard Worker
222*9880d681SAndroid Build Coastguard Worker; POWER8: addis [[REGSTRUCT:[0-9]+]], 2, h4v@toc@ha
223*9880d681SAndroid Build Coastguard Worker; POWER8-NEXT: addi [[REGSTRUCT]], [[REGSTRUCT]], h4v@toc@l
224*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lhz [[REG0_0:[0-9]+]], 0([[REGSTRUCT]])
225*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lhz [[REG1_0:[0-9]+]], 2([[REGSTRUCT]])
226*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lhz [[REG2_0:[0-9]+]], 4([[REGSTRUCT]])
227*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lhz [[REG3_0:[0-9]+]], 6([[REGSTRUCT]])
228*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
229*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
230*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG2_1:[0-9]+]], [[REG2_0]], 3
231*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG3_1:[0-9]+]], [[REG3_0]], 4
232*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: sth [[REG0_1]], 0([[REGSTRUCT]])
233*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: sth [[REG1_1]], 2([[REGSTRUCT]])
234*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: sth [[REG2_1]], 4([[REGSTRUCT]])
235*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: sth [[REG3_1]], 6([[REGSTRUCT]])
236*9880d681SAndroid Build Coastguard Workerdefine void @test_h4() nounwind {
237*9880d681SAndroid Build Coastguard Workerentry:
238*9880d681SAndroid Build Coastguard Worker  %0 = load i16, i16* getelementptr inbounds (%struct.h4, %struct.h4* @h4v, i32 0, i32 0), align 2
239*9880d681SAndroid Build Coastguard Worker  %inc0 = add nsw i16 %0, 1
240*9880d681SAndroid Build Coastguard Worker  store i16 %inc0, i16* getelementptr inbounds (%struct.h4, %struct.h4* @h4v, i32 0, i32 0), align 2
241*9880d681SAndroid Build Coastguard Worker  %1 = load i16, i16* getelementptr inbounds (%struct.h4, %struct.h4* @h4v, i32 0, i32 1), align 2
242*9880d681SAndroid Build Coastguard Worker  %inc1 = add nsw i16 %1, 2
243*9880d681SAndroid Build Coastguard Worker  store i16 %inc1, i16* getelementptr inbounds (%struct.h4, %struct.h4* @h4v, i32 0, i32 1), align 2
244*9880d681SAndroid Build Coastguard Worker  %2 = load i16, i16* getelementptr inbounds (%struct.h4, %struct.h4* @h4v, i32 0, i32 2), align 2
245*9880d681SAndroid Build Coastguard Worker  %inc2 = add nsw i16 %2, 3
246*9880d681SAndroid Build Coastguard Worker  store i16 %inc2, i16* getelementptr inbounds (%struct.h4, %struct.h4* @h4v, i32 0, i32 2), align 2
247*9880d681SAndroid Build Coastguard Worker  %3 = load i16, i16* getelementptr inbounds (%struct.h4, %struct.h4* @h4v, i32 0, i32 3), align 2
248*9880d681SAndroid Build Coastguard Worker  %inc3 = add nsw i16 %3, 4
249*9880d681SAndroid Build Coastguard Worker  store i16 %inc3, i16* getelementptr inbounds (%struct.h4, %struct.h4* @h4v, i32 0, i32 3), align 2
250*9880d681SAndroid Build Coastguard Worker  ret void
251*9880d681SAndroid Build Coastguard Worker}
252*9880d681SAndroid Build Coastguard Worker
253*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_w2:
254*9880d681SAndroid Build Coastguard Worker; POWER7: addis [[REGSTRUCT:[0-9]+]], 2, w2v@toc@ha
255*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lwz [[REG0_0:[0-9]+]], w2v@toc@l([[REGSTRUCT]])
256*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: lwz [[REG1_0:[0-9]+]], w2v@toc@l+4([[REGSTRUCT]])
257*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
258*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
259*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stw [[REG0_1]], w2v@toc@l([[REGSTRUCT]])
260*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: stw [[REG1_1]], w2v@toc@l+4([[REGSTRUCT]])
261*9880d681SAndroid Build Coastguard Worker
262*9880d681SAndroid Build Coastguard Worker; POWER8: addis [[REGSTRUCT:[0-9]+]], 2, w2v@toc@ha
263*9880d681SAndroid Build Coastguard Worker; POWER8-NEXT: addi [[REGSTRUCT]], [[REGSTRUCT]], w2v@toc@l
264*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lwz [[REG0_0:[0-9]+]], 0([[REGSTRUCT]])
265*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: lwz [[REG1_0:[0-9]+]], 4([[REGSTRUCT]])
266*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
267*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
268*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stw [[REG0_1]], 0([[REGSTRUCT]])
269*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: stw [[REG1_1]], 4([[REGSTRUCT]])
270*9880d681SAndroid Build Coastguard Workerdefine void @test_w2() nounwind {
271*9880d681SAndroid Build Coastguard Workerentry:
272*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* getelementptr inbounds (%struct.w2, %struct.w2* @w2v, i32 0, i32 0), align 4
273*9880d681SAndroid Build Coastguard Worker  %inc0 = add nsw i32 %0, 1
274*9880d681SAndroid Build Coastguard Worker  store i32 %inc0, i32* getelementptr inbounds (%struct.w2, %struct.w2* @w2v, i32 0, i32 0), align 4
275*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* getelementptr inbounds (%struct.w2, %struct.w2* @w2v, i32 0, i32 1), align 4
276*9880d681SAndroid Build Coastguard Worker  %inc1 = add nsw i32 %1, 2
277*9880d681SAndroid Build Coastguard Worker  store i32 %inc1, i32* getelementptr inbounds (%struct.w2, %struct.w2* @w2v, i32 0, i32 1), align 4
278*9880d681SAndroid Build Coastguard Worker  ret void
279*9880d681SAndroid Build Coastguard Worker}
280*9880d681SAndroid Build Coastguard Worker
281*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_d2:
282*9880d681SAndroid Build Coastguard Worker; POWER7: addis [[REGSTRUCT:[0-9]+]], 2, d2v@toc@ha
283*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: ld [[REG0_0:[0-9]+]], d2v@toc@l([[REGSTRUCT]])
284*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: ld [[REG1_0:[0-9]+]], d2v@toc@l+8([[REGSTRUCT]])
285*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
286*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
287*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: std [[REG0_1]], d2v@toc@l([[REGSTRUCT]])
288*9880d681SAndroid Build Coastguard Worker; POWER7-DAG: std [[REG1_1]], d2v@toc@l+8([[REGSTRUCT]])
289*9880d681SAndroid Build Coastguard Worker
290*9880d681SAndroid Build Coastguard Worker; POWER8: addis [[REGSTRUCT:[0-9]+]], 2, d2v@toc@ha
291*9880d681SAndroid Build Coastguard Worker; POWER8-NEXT: addi [[REGSTRUCT]], [[REGSTRUCT]], d2v@toc@l
292*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: ld [[REG0_0:[0-9]+]], 0([[REGSTRUCT]])
293*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: ld [[REG1_0:[0-9]+]], 8([[REGSTRUCT]])
294*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
295*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: addi [[REG1_1:[0-9]+]], [[REG1_0]], 2
296*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: std [[REG0_1]], 0([[REGSTRUCT]])
297*9880d681SAndroid Build Coastguard Worker; POWER8-DAG: std [[REG1_1]], 8([[REGSTRUCT]])
298*9880d681SAndroid Build Coastguard Workerdefine void @test_d2() nounwind {
299*9880d681SAndroid Build Coastguard Workerentry:
300*9880d681SAndroid Build Coastguard Worker  %0 = load i64, i64* getelementptr inbounds (%struct.d2, %struct.d2* @d2v, i32 0, i32 0), align 8
301*9880d681SAndroid Build Coastguard Worker  %inc0 = add nsw i64 %0, 1
302*9880d681SAndroid Build Coastguard Worker  store i64 %inc0, i64* getelementptr inbounds (%struct.d2, %struct.d2* @d2v, i32 0, i32 0), align 8
303*9880d681SAndroid Build Coastguard Worker  %1 = load i64, i64* getelementptr inbounds (%struct.d2, %struct.d2* @d2v, i32 0, i32 1), align 8
304*9880d681SAndroid Build Coastguard Worker  %inc1 = add nsw i64 %1, 2
305*9880d681SAndroid Build Coastguard Worker  store i64 %inc1, i64* getelementptr inbounds (%struct.d2, %struct.d2* @d2v, i32 0, i32 1), align 8
306*9880d681SAndroid Build Coastguard Worker  ret void
307*9880d681SAndroid Build Coastguard Worker}
308*9880d681SAndroid Build Coastguard Worker
309*9880d681SAndroid Build Coastguard Worker; Make sure the optimization fires on power8 if there is a single use resulting
310*9880d681SAndroid Build Coastguard Worker; in a better fusion opportunity.
311*9880d681SAndroid Build Coastguard Worker; register 3 is the return value, so it should be chosen
312*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_singleuse:
313*9880d681SAndroid Build Coastguard Worker; CHECK: addis 3, 2, d2v@toc@ha
314*9880d681SAndroid Build Coastguard Worker; CHECK: ld 3, d2v@toc@l+8(3)
315*9880d681SAndroid Build Coastguard Workerdefine i64 @test_singleuse() nounwind {
316*9880d681SAndroid Build Coastguard Workerentry:
317*9880d681SAndroid Build Coastguard Worker  %0 = load i64, i64* getelementptr inbounds (%struct.d2, %struct.d2* @d2v, i32 0, i32 1), align 8
318*9880d681SAndroid Build Coastguard Worker  ret i64 %0
319*9880d681SAndroid Build Coastguard Worker}
320*9880d681SAndroid Build Coastguard Worker
321*9880d681SAndroid Build Coastguard Worker; Make sure the optimization fails to fire if the symbol is aligned, but the offset is not.
322*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_misalign
323*9880d681SAndroid Build Coastguard Worker; POWER7: addis [[REGSTRUCT_0:[0-9]+]], 2, misalign_v@toc@ha
324*9880d681SAndroid Build Coastguard Worker; POWER7: addi [[REGSTRUCT:[0-9]+]], [[REGSTRUCT_0]], misalign_v@toc@l
325*9880d681SAndroid Build Coastguard Worker; POWER7: li [[OFFSET_REG:[0-9]+]], 1
326*9880d681SAndroid Build Coastguard Worker; POWER7: ldx [[REG0_0:[0-9]+]], [[REGSTRUCT]], [[OFFSET_REG]]
327*9880d681SAndroid Build Coastguard Worker; POWER7: addi [[REG0_1:[0-9]+]], [[REG0_0]], 1
328*9880d681SAndroid Build Coastguard Worker; POWER7: stdx [[REG0_1]], [[REGSTRUCT]], [[OFFSET_REG]]
329*9880d681SAndroid Build Coastguard Workerdefine void @test_misalign() nounwind {
330*9880d681SAndroid Build Coastguard Workerentry:
331*9880d681SAndroid Build Coastguard Worker  %0 = load i64, i64* getelementptr inbounds (%struct.misalign, %struct.misalign* @misalign_v, i32 0, i32 1), align 1
332*9880d681SAndroid Build Coastguard Worker  %inc0 = add nsw i64 %0, 1
333*9880d681SAndroid Build Coastguard Worker  store i64 %inc0, i64* getelementptr inbounds (%struct.misalign, %struct.misalign* @misalign_v, i32 0, i32 1), align 1
334*9880d681SAndroid Build Coastguard Worker  ret void
335*9880d681SAndroid Build Coastguard Worker}
336