1 //===- PPCInstrVSX.td - The PowerPC VSX Extension --*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the VSX extension to the PowerPC instruction set.
11 //===----------------------------------------------------------------------===//
13 // *********************************** NOTE ***********************************
14 // ** For POWER8 Little Endian, the VSX swap optimization relies on knowing **
15 // ** which VMX and VSX instructions are lane-sensitive and which are not. **
16 // ** A lane-sensitive instruction relies, implicitly or explicitly, on **
17 // ** whether lanes are numbered from left to right. An instruction like **
18 // ** VADDFP is not lane-sensitive, because each lane of the result vector **
19 // ** relies only on the corresponding lane of the source vectors. However, **
20 // ** an instruction like VMULESB is lane-sensitive, because "even" and **
21 // ** "odd" lanes are different for big-endian and little-endian numbering. **
23 // ** When adding new VMX and VSX instructions, please consider whether they **
24 // ** are lane-sensitive. If so, they must be added to a switch statement **
25 // ** in PPCVSXSwapRemoval::gatherVectorInstructions(). **
26 // ****************************************************************************
28 def PPCRegVSRCAsmOperand : AsmOperandClass {
29 let Name = "RegVSRC"; let PredicateMethod = "isVSRegNumber";
31 def vsrc : RegisterOperand<VSRC> {
32 let ParserMatchClass = PPCRegVSRCAsmOperand;
35 def PPCRegVSFRCAsmOperand : AsmOperandClass {
36 let Name = "RegVSFRC"; let PredicateMethod = "isVSRegNumber";
38 def vsfrc : RegisterOperand<VSFRC> {
39 let ParserMatchClass = PPCRegVSFRCAsmOperand;
42 def PPCRegVSSRCAsmOperand : AsmOperandClass {
43 let Name = "RegVSSRC"; let PredicateMethod = "isVSRegNumber";
45 def vssrc : RegisterOperand<VSSRC> {
46 let ParserMatchClass = PPCRegVSSRCAsmOperand;
49 def PPCRegSPILLTOVSRRCAsmOperand : AsmOperandClass {
50 let Name = "RegSPILLTOVSRRC"; let PredicateMethod = "isVSRegNumber";
53 def spilltovsrrc : RegisterOperand<SPILLTOVSRRC> {
54 let ParserMatchClass = PPCRegSPILLTOVSRRCAsmOperand;
56 // Little-endian-specific nodes.
57 def SDT_PPClxvd2x : SDTypeProfile<1, 1, [
58 SDTCisVT<0, v2f64>, SDTCisPtrTy<1>
60 def SDT_PPCstxvd2x : SDTypeProfile<0, 2, [
61 SDTCisVT<0, v2f64>, SDTCisPtrTy<1>
63 def SDT_PPCxxswapd : SDTypeProfile<1, 1, [
66 def SDTVecConv : SDTypeProfile<1, 2, [
67 SDTCisVec<0>, SDTCisVec<1>, SDTCisPtrTy<2>
69 def SDTVabsd : SDTypeProfile<1, 3, [
70 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVT<3, i32>
74 def PPClxvd2x : SDNode<"PPCISD::LXVD2X", SDT_PPClxvd2x,
75 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
76 def PPCstxvd2x : SDNode<"PPCISD::STXVD2X", SDT_PPCstxvd2x,
77 [SDNPHasChain, SDNPMayStore]>;
78 def PPCxxswapd : SDNode<"PPCISD::XXSWAPD", SDT_PPCxxswapd, [SDNPHasChain]>;
79 def PPCmfvsr : SDNode<"PPCISD::MFVSR", SDTUnaryOp, []>;
80 def PPCmtvsra : SDNode<"PPCISD::MTVSRA", SDTUnaryOp, []>;
81 def PPCmtvsrz : SDNode<"PPCISD::MTVSRZ", SDTUnaryOp, []>;
82 def PPCsvec2fp : SDNode<"PPCISD::SINT_VEC_TO_FP", SDTVecConv, []>;
83 def PPCuvec2fp: SDNode<"PPCISD::UINT_VEC_TO_FP", SDTVecConv, []>;
84 def PPCswapNoChain : SDNode<"PPCISD::SWAP_NO_CHAIN", SDT_PPCxxswapd>;
85 def PPCvabsd : SDNode<"PPCISD::VABSD", SDTVabsd, []>;
87 multiclass XX3Form_Rcr<bits<6> opcode, bits<7> xo, string asmbase,
88 string asmstr, InstrItinClass itin, Intrinsic Int,
89 ValueType OutTy, ValueType InTy> {
90 let BaseName = asmbase in {
91 def NAME : XX3Form_Rc<opcode, xo, (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
92 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
93 [(set OutTy:$XT, (Int InTy:$XA, InTy:$XB))]>;
95 def o : XX3Form_Rc<opcode, xo, (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
96 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
98 (InTy (PPCvcmp_o InTy:$XA, InTy:$XB, xo)))]>,
103 // Instruction form with a single input register for instructions such as
104 // XXPERMDI. The reason for defining this is that specifying multiple chained
105 // operands (such as loads) to an instruction will perform both chained
106 // operations rather than coalescing them into a single register - even though
107 // the source memory location is the same. This simply forces the instruction
108 // to use the same register for both inputs.
109 // For example, an output DAG such as this:
110 // (XXPERMDI (LXSIBZX xoaddr:$src), (LXSIBZX xoaddr:$src ), 0))
111 // would result in two load instructions emitted and used as separate inputs
112 // to the XXPERMDI instruction.
113 class XX3Form_2s<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, string asmstr,
114 InstrItinClass itin, list<dag> pattern>
115 : XX3Form_2<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
119 def HasVSX : Predicate<"PPCSubTarget->hasVSX()">;
120 def IsLittleEndian : Predicate<"PPCSubTarget->isLittleEndian()">;
121 def IsBigEndian : Predicate<"!PPCSubTarget->isLittleEndian()">;
122 def HasOnlySwappingMemOps : Predicate<"!PPCSubTarget->hasP9Vector()">;
124 let Predicates = [HasVSX] in {
125 let AddedComplexity = 400 in { // Prefer VSX patterns over non-VSX patterns.
126 let UseVSXReg = 1 in {
127 let hasSideEffects = 0 in { // VSX instructions don't have side effects.
130 // Load indexed instructions
131 let mayLoad = 1, mayStore = 0 in {
133 def LXSDX : XX1Form_memOp<31, 588,
134 (outs vsfrc:$XT), (ins memrr:$src),
135 "lxsdx $XT, $src", IIC_LdStLFD,
138 // Pseudo instruction XFLOADf64 will be expanded to LXSDX or LFDX later
140 def XFLOADf64 : PseudoXFormMemOp<(outs vsfrc:$XT), (ins memrr:$src),
142 [(set f64:$XT, (load xoaddr:$src))]>;
144 let Predicates = [HasVSX, HasOnlySwappingMemOps] in
145 def LXVD2X : XX1Form_memOp<31, 844,
146 (outs vsrc:$XT), (ins memrr:$src),
147 "lxvd2x $XT, $src", IIC_LdStLFD,
148 [(set v2f64:$XT, (int_ppc_vsx_lxvd2x xoaddr:$src))]>;
150 def LXVDSX : XX1Form_memOp<31, 332,
151 (outs vsrc:$XT), (ins memrr:$src),
152 "lxvdsx $XT, $src", IIC_LdStLFD, []>;
154 let Predicates = [HasVSX, HasOnlySwappingMemOps] in
155 def LXVW4X : XX1Form_memOp<31, 780,
156 (outs vsrc:$XT), (ins memrr:$src),
157 "lxvw4x $XT, $src", IIC_LdStLFD,
161 // Store indexed instructions
162 let mayStore = 1, mayLoad = 0 in {
164 def STXSDX : XX1Form_memOp<31, 716,
165 (outs), (ins vsfrc:$XT, memrr:$dst),
166 "stxsdx $XT, $dst", IIC_LdStSTFD,
169 // Pseudo instruction XFSTOREf64 will be expanded to STXSDX or STFDX later
171 def XFSTOREf64 : PseudoXFormMemOp<(outs), (ins vsfrc:$XT, memrr:$dst),
173 [(store f64:$XT, xoaddr:$dst)]>;
175 let Predicates = [HasVSX, HasOnlySwappingMemOps] in {
176 // The behaviour of this instruction is endianness-specific so we provide no
177 // pattern to match it without considering endianness.
178 def STXVD2X : XX1Form_memOp<31, 972,
179 (outs), (ins vsrc:$XT, memrr:$dst),
180 "stxvd2x $XT, $dst", IIC_LdStSTFD,
183 def STXVW4X : XX1Form_memOp<31, 908,
184 (outs), (ins vsrc:$XT, memrr:$dst),
185 "stxvw4x $XT, $dst", IIC_LdStSTFD,
190 // Add/Mul Instructions
191 let isCommutable = 1 in {
192 def XSADDDP : XX3Form<60, 32,
193 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
194 "xsadddp $XT, $XA, $XB", IIC_VecFP,
195 [(set f64:$XT, (fadd f64:$XA, f64:$XB))]>;
196 def XSMULDP : XX3Form<60, 48,
197 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
198 "xsmuldp $XT, $XA, $XB", IIC_VecFP,
199 [(set f64:$XT, (fmul f64:$XA, f64:$XB))]>;
201 def XVADDDP : XX3Form<60, 96,
202 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
203 "xvadddp $XT, $XA, $XB", IIC_VecFP,
204 [(set v2f64:$XT, (fadd v2f64:$XA, v2f64:$XB))]>;
206 def XVADDSP : XX3Form<60, 64,
207 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
208 "xvaddsp $XT, $XA, $XB", IIC_VecFP,
209 [(set v4f32:$XT, (fadd v4f32:$XA, v4f32:$XB))]>;
211 def XVMULDP : XX3Form<60, 112,
212 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
213 "xvmuldp $XT, $XA, $XB", IIC_VecFP,
214 [(set v2f64:$XT, (fmul v2f64:$XA, v2f64:$XB))]>;
216 def XVMULSP : XX3Form<60, 80,
217 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
218 "xvmulsp $XT, $XA, $XB", IIC_VecFP,
219 [(set v4f32:$XT, (fmul v4f32:$XA, v4f32:$XB))]>;
222 // Subtract Instructions
223 def XSSUBDP : XX3Form<60, 40,
224 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
225 "xssubdp $XT, $XA, $XB", IIC_VecFP,
226 [(set f64:$XT, (fsub f64:$XA, f64:$XB))]>;
228 def XVSUBDP : XX3Form<60, 104,
229 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
230 "xvsubdp $XT, $XA, $XB", IIC_VecFP,
231 [(set v2f64:$XT, (fsub v2f64:$XA, v2f64:$XB))]>;
232 def XVSUBSP : XX3Form<60, 72,
233 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
234 "xvsubsp $XT, $XA, $XB", IIC_VecFP,
235 [(set v4f32:$XT, (fsub v4f32:$XA, v4f32:$XB))]>;
238 let BaseName = "XSMADDADP" in {
239 let isCommutable = 1 in
240 def XSMADDADP : XX3Form<60, 33,
241 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
242 "xsmaddadp $XT, $XA, $XB", IIC_VecFP,
243 [(set f64:$XT, (fma f64:$XA, f64:$XB, f64:$XTi))]>,
244 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
246 let IsVSXFMAAlt = 1 in
247 def XSMADDMDP : XX3Form<60, 41,
248 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
249 "xsmaddmdp $XT, $XA, $XB", IIC_VecFP, []>,
250 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
254 let BaseName = "XSMSUBADP" in {
255 let isCommutable = 1 in
256 def XSMSUBADP : XX3Form<60, 49,
257 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
258 "xsmsubadp $XT, $XA, $XB", IIC_VecFP,
259 [(set f64:$XT, (fma f64:$XA, f64:$XB, (fneg f64:$XTi)))]>,
260 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
262 let IsVSXFMAAlt = 1 in
263 def XSMSUBMDP : XX3Form<60, 57,
264 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
265 "xsmsubmdp $XT, $XA, $XB", IIC_VecFP, []>,
266 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
270 let BaseName = "XSNMADDADP" in {
271 let isCommutable = 1 in
272 def XSNMADDADP : XX3Form<60, 161,
273 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
274 "xsnmaddadp $XT, $XA, $XB", IIC_VecFP,
275 [(set f64:$XT, (fneg (fma f64:$XA, f64:$XB, f64:$XTi)))]>,
276 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
278 let IsVSXFMAAlt = 1 in
279 def XSNMADDMDP : XX3Form<60, 169,
280 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
281 "xsnmaddmdp $XT, $XA, $XB", IIC_VecFP, []>,
282 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
286 let BaseName = "XSNMSUBADP" in {
287 let isCommutable = 1 in
288 def XSNMSUBADP : XX3Form<60, 177,
289 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
290 "xsnmsubadp $XT, $XA, $XB", IIC_VecFP,
291 [(set f64:$XT, (fneg (fma f64:$XA, f64:$XB, (fneg f64:$XTi))))]>,
292 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
294 let IsVSXFMAAlt = 1 in
295 def XSNMSUBMDP : XX3Form<60, 185,
296 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
297 "xsnmsubmdp $XT, $XA, $XB", IIC_VecFP, []>,
298 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
302 let BaseName = "XVMADDADP" in {
303 let isCommutable = 1 in
304 def XVMADDADP : XX3Form<60, 97,
305 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
306 "xvmaddadp $XT, $XA, $XB", IIC_VecFP,
307 [(set v2f64:$XT, (fma v2f64:$XA, v2f64:$XB, v2f64:$XTi))]>,
308 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
310 let IsVSXFMAAlt = 1 in
311 def XVMADDMDP : XX3Form<60, 105,
312 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
313 "xvmaddmdp $XT, $XA, $XB", IIC_VecFP, []>,
314 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
318 let BaseName = "XVMADDASP" in {
319 let isCommutable = 1 in
320 def XVMADDASP : XX3Form<60, 65,
321 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
322 "xvmaddasp $XT, $XA, $XB", IIC_VecFP,
323 [(set v4f32:$XT, (fma v4f32:$XA, v4f32:$XB, v4f32:$XTi))]>,
324 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
326 let IsVSXFMAAlt = 1 in
327 def XVMADDMSP : XX3Form<60, 73,
328 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
329 "xvmaddmsp $XT, $XA, $XB", IIC_VecFP, []>,
330 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
334 let BaseName = "XVMSUBADP" in {
335 let isCommutable = 1 in
336 def XVMSUBADP : XX3Form<60, 113,
337 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
338 "xvmsubadp $XT, $XA, $XB", IIC_VecFP,
339 [(set v2f64:$XT, (fma v2f64:$XA, v2f64:$XB, (fneg v2f64:$XTi)))]>,
340 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
342 let IsVSXFMAAlt = 1 in
343 def XVMSUBMDP : XX3Form<60, 121,
344 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
345 "xvmsubmdp $XT, $XA, $XB", IIC_VecFP, []>,
346 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
350 let BaseName = "XVMSUBASP" in {
351 let isCommutable = 1 in
352 def XVMSUBASP : XX3Form<60, 81,
353 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
354 "xvmsubasp $XT, $XA, $XB", IIC_VecFP,
355 [(set v4f32:$XT, (fma v4f32:$XA, v4f32:$XB, (fneg v4f32:$XTi)))]>,
356 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
358 let IsVSXFMAAlt = 1 in
359 def XVMSUBMSP : XX3Form<60, 89,
360 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
361 "xvmsubmsp $XT, $XA, $XB", IIC_VecFP, []>,
362 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
366 let BaseName = "XVNMADDADP" in {
367 let isCommutable = 1 in
368 def XVNMADDADP : XX3Form<60, 225,
369 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
370 "xvnmaddadp $XT, $XA, $XB", IIC_VecFP,
371 [(set v2f64:$XT, (fneg (fma v2f64:$XA, v2f64:$XB, v2f64:$XTi)))]>,
372 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
374 let IsVSXFMAAlt = 1 in
375 def XVNMADDMDP : XX3Form<60, 233,
376 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
377 "xvnmaddmdp $XT, $XA, $XB", IIC_VecFP, []>,
378 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
382 let BaseName = "XVNMADDASP" in {
383 let isCommutable = 1 in
384 def XVNMADDASP : XX3Form<60, 193,
385 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
386 "xvnmaddasp $XT, $XA, $XB", IIC_VecFP,
387 [(set v4f32:$XT, (fneg (fma v4f32:$XA, v4f32:$XB, v4f32:$XTi)))]>,
388 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
390 let IsVSXFMAAlt = 1 in
391 def XVNMADDMSP : XX3Form<60, 201,
392 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
393 "xvnmaddmsp $XT, $XA, $XB", IIC_VecFP, []>,
394 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
398 let BaseName = "XVNMSUBADP" in {
399 let isCommutable = 1 in
400 def XVNMSUBADP : XX3Form<60, 241,
401 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
402 "xvnmsubadp $XT, $XA, $XB", IIC_VecFP,
403 [(set v2f64:$XT, (fneg (fma v2f64:$XA, v2f64:$XB, (fneg v2f64:$XTi))))]>,
404 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
406 let IsVSXFMAAlt = 1 in
407 def XVNMSUBMDP : XX3Form<60, 249,
408 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
409 "xvnmsubmdp $XT, $XA, $XB", IIC_VecFP, []>,
410 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
414 let BaseName = "XVNMSUBASP" in {
415 let isCommutable = 1 in
416 def XVNMSUBASP : XX3Form<60, 209,
417 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
418 "xvnmsubasp $XT, $XA, $XB", IIC_VecFP,
419 [(set v4f32:$XT, (fneg (fma v4f32:$XA, v4f32:$XB, (fneg v4f32:$XTi))))]>,
420 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
422 let IsVSXFMAAlt = 1 in
423 def XVNMSUBMSP : XX3Form<60, 217,
424 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
425 "xvnmsubmsp $XT, $XA, $XB", IIC_VecFP, []>,
426 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
430 // Division Instructions
431 def XSDIVDP : XX3Form<60, 56,
432 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
433 "xsdivdp $XT, $XA, $XB", IIC_FPDivD,
434 [(set f64:$XT, (fdiv f64:$XA, f64:$XB))]>;
435 def XSSQRTDP : XX2Form<60, 75,
436 (outs vsfrc:$XT), (ins vsfrc:$XB),
437 "xssqrtdp $XT, $XB", IIC_FPSqrtD,
438 [(set f64:$XT, (fsqrt f64:$XB))]>;
440 def XSREDP : XX2Form<60, 90,
441 (outs vsfrc:$XT), (ins vsfrc:$XB),
442 "xsredp $XT, $XB", IIC_VecFP,
443 [(set f64:$XT, (PPCfre f64:$XB))]>;
444 def XSRSQRTEDP : XX2Form<60, 74,
445 (outs vsfrc:$XT), (ins vsfrc:$XB),
446 "xsrsqrtedp $XT, $XB", IIC_VecFP,
447 [(set f64:$XT, (PPCfrsqrte f64:$XB))]>;
449 def XSTDIVDP : XX3Form_1<60, 61,
450 (outs crrc:$crD), (ins vsfrc:$XA, vsfrc:$XB),
451 "xstdivdp $crD, $XA, $XB", IIC_FPCompare, []>;
452 def XSTSQRTDP : XX2Form_1<60, 106,
453 (outs crrc:$crD), (ins vsfrc:$XB),
454 "xstsqrtdp $crD, $XB", IIC_FPCompare, []>;
456 def XVDIVDP : XX3Form<60, 120,
457 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
458 "xvdivdp $XT, $XA, $XB", IIC_FPDivD,
459 [(set v2f64:$XT, (fdiv v2f64:$XA, v2f64:$XB))]>;
460 def XVDIVSP : XX3Form<60, 88,
461 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
462 "xvdivsp $XT, $XA, $XB", IIC_FPDivS,
463 [(set v4f32:$XT, (fdiv v4f32:$XA, v4f32:$XB))]>;
465 def XVSQRTDP : XX2Form<60, 203,
466 (outs vsrc:$XT), (ins vsrc:$XB),
467 "xvsqrtdp $XT, $XB", IIC_FPSqrtD,
468 [(set v2f64:$XT, (fsqrt v2f64:$XB))]>;
469 def XVSQRTSP : XX2Form<60, 139,
470 (outs vsrc:$XT), (ins vsrc:$XB),
471 "xvsqrtsp $XT, $XB", IIC_FPSqrtS,
472 [(set v4f32:$XT, (fsqrt v4f32:$XB))]>;
474 def XVTDIVDP : XX3Form_1<60, 125,
475 (outs crrc:$crD), (ins vsrc:$XA, vsrc:$XB),
476 "xvtdivdp $crD, $XA, $XB", IIC_FPCompare, []>;
477 def XVTDIVSP : XX3Form_1<60, 93,
478 (outs crrc:$crD), (ins vsrc:$XA, vsrc:$XB),
479 "xvtdivsp $crD, $XA, $XB", IIC_FPCompare, []>;
481 def XVTSQRTDP : XX2Form_1<60, 234,
482 (outs crrc:$crD), (ins vsrc:$XB),
483 "xvtsqrtdp $crD, $XB", IIC_FPCompare, []>;
484 def XVTSQRTSP : XX2Form_1<60, 170,
485 (outs crrc:$crD), (ins vsrc:$XB),
486 "xvtsqrtsp $crD, $XB", IIC_FPCompare, []>;
488 def XVREDP : XX2Form<60, 218,
489 (outs vsrc:$XT), (ins vsrc:$XB),
490 "xvredp $XT, $XB", IIC_VecFP,
491 [(set v2f64:$XT, (PPCfre v2f64:$XB))]>;
492 def XVRESP : XX2Form<60, 154,
493 (outs vsrc:$XT), (ins vsrc:$XB),
494 "xvresp $XT, $XB", IIC_VecFP,
495 [(set v4f32:$XT, (PPCfre v4f32:$XB))]>;
497 def XVRSQRTEDP : XX2Form<60, 202,
498 (outs vsrc:$XT), (ins vsrc:$XB),
499 "xvrsqrtedp $XT, $XB", IIC_VecFP,
500 [(set v2f64:$XT, (PPCfrsqrte v2f64:$XB))]>;
501 def XVRSQRTESP : XX2Form<60, 138,
502 (outs vsrc:$XT), (ins vsrc:$XB),
503 "xvrsqrtesp $XT, $XB", IIC_VecFP,
504 [(set v4f32:$XT, (PPCfrsqrte v4f32:$XB))]>;
506 // Compare Instructions
507 def XSCMPODP : XX3Form_1<60, 43,
508 (outs crrc:$crD), (ins vsfrc:$XA, vsfrc:$XB),
509 "xscmpodp $crD, $XA, $XB", IIC_FPCompare, []>;
510 def XSCMPUDP : XX3Form_1<60, 35,
511 (outs crrc:$crD), (ins vsfrc:$XA, vsfrc:$XB),
512 "xscmpudp $crD, $XA, $XB", IIC_FPCompare, []>;
514 defm XVCMPEQDP : XX3Form_Rcr<60, 99,
515 "xvcmpeqdp", "$XT, $XA, $XB", IIC_VecFPCompare,
516 int_ppc_vsx_xvcmpeqdp, v2i64, v2f64>;
517 defm XVCMPEQSP : XX3Form_Rcr<60, 67,
518 "xvcmpeqsp", "$XT, $XA, $XB", IIC_VecFPCompare,
519 int_ppc_vsx_xvcmpeqsp, v4i32, v4f32>;
520 defm XVCMPGEDP : XX3Form_Rcr<60, 115,
521 "xvcmpgedp", "$XT, $XA, $XB", IIC_VecFPCompare,
522 int_ppc_vsx_xvcmpgedp, v2i64, v2f64>;
523 defm XVCMPGESP : XX3Form_Rcr<60, 83,
524 "xvcmpgesp", "$XT, $XA, $XB", IIC_VecFPCompare,
525 int_ppc_vsx_xvcmpgesp, v4i32, v4f32>;
526 defm XVCMPGTDP : XX3Form_Rcr<60, 107,
527 "xvcmpgtdp", "$XT, $XA, $XB", IIC_VecFPCompare,
528 int_ppc_vsx_xvcmpgtdp, v2i64, v2f64>;
529 defm XVCMPGTSP : XX3Form_Rcr<60, 75,
530 "xvcmpgtsp", "$XT, $XA, $XB", IIC_VecFPCompare,
531 int_ppc_vsx_xvcmpgtsp, v4i32, v4f32>;
534 def XSABSDP : XX2Form<60, 345,
535 (outs vsfrc:$XT), (ins vsfrc:$XB),
536 "xsabsdp $XT, $XB", IIC_VecFP,
537 [(set f64:$XT, (fabs f64:$XB))]>;
538 def XSNABSDP : XX2Form<60, 361,
539 (outs vsfrc:$XT), (ins vsfrc:$XB),
540 "xsnabsdp $XT, $XB", IIC_VecFP,
541 [(set f64:$XT, (fneg (fabs f64:$XB)))]>;
542 def XSNEGDP : XX2Form<60, 377,
543 (outs vsfrc:$XT), (ins vsfrc:$XB),
544 "xsnegdp $XT, $XB", IIC_VecFP,
545 [(set f64:$XT, (fneg f64:$XB))]>;
546 def XSCPSGNDP : XX3Form<60, 176,
547 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
548 "xscpsgndp $XT, $XA, $XB", IIC_VecFP,
549 [(set f64:$XT, (fcopysign f64:$XB, f64:$XA))]>;
551 def XVABSDP : XX2Form<60, 473,
552 (outs vsrc:$XT), (ins vsrc:$XB),
553 "xvabsdp $XT, $XB", IIC_VecFP,
554 [(set v2f64:$XT, (fabs v2f64:$XB))]>;
556 def XVABSSP : XX2Form<60, 409,
557 (outs vsrc:$XT), (ins vsrc:$XB),
558 "xvabssp $XT, $XB", IIC_VecFP,
559 [(set v4f32:$XT, (fabs v4f32:$XB))]>;
561 def XVCPSGNDP : XX3Form<60, 240,
562 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
563 "xvcpsgndp $XT, $XA, $XB", IIC_VecFP,
564 [(set v2f64:$XT, (fcopysign v2f64:$XB, v2f64:$XA))]>;
565 def XVCPSGNSP : XX3Form<60, 208,
566 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
567 "xvcpsgnsp $XT, $XA, $XB", IIC_VecFP,
568 [(set v4f32:$XT, (fcopysign v4f32:$XB, v4f32:$XA))]>;
570 def XVNABSDP : XX2Form<60, 489,
571 (outs vsrc:$XT), (ins vsrc:$XB),
572 "xvnabsdp $XT, $XB", IIC_VecFP,
573 [(set v2f64:$XT, (fneg (fabs v2f64:$XB)))]>;
574 def XVNABSSP : XX2Form<60, 425,
575 (outs vsrc:$XT), (ins vsrc:$XB),
576 "xvnabssp $XT, $XB", IIC_VecFP,
577 [(set v4f32:$XT, (fneg (fabs v4f32:$XB)))]>;
579 def XVNEGDP : XX2Form<60, 505,
580 (outs vsrc:$XT), (ins vsrc:$XB),
581 "xvnegdp $XT, $XB", IIC_VecFP,
582 [(set v2f64:$XT, (fneg v2f64:$XB))]>;
583 def XVNEGSP : XX2Form<60, 441,
584 (outs vsrc:$XT), (ins vsrc:$XB),
585 "xvnegsp $XT, $XB", IIC_VecFP,
586 [(set v4f32:$XT, (fneg v4f32:$XB))]>;
588 // Conversion Instructions
589 def XSCVDPSP : XX2Form<60, 265,
590 (outs vsfrc:$XT), (ins vsfrc:$XB),
591 "xscvdpsp $XT, $XB", IIC_VecFP, []>;
592 def XSCVDPSXDS : XX2Form<60, 344,
593 (outs vsfrc:$XT), (ins vsfrc:$XB),
594 "xscvdpsxds $XT, $XB", IIC_VecFP,
595 [(set f64:$XT, (PPCfctidz f64:$XB))]>;
596 let isCodeGenOnly = 1 in
597 def XSCVDPSXDSs : XX2Form<60, 344,
598 (outs vssrc:$XT), (ins vssrc:$XB),
599 "xscvdpsxds $XT, $XB", IIC_VecFP,
600 [(set f32:$XT, (PPCfctidz f32:$XB))]>;
601 def XSCVDPSXWS : XX2Form<60, 88,
602 (outs vsfrc:$XT), (ins vsfrc:$XB),
603 "xscvdpsxws $XT, $XB", IIC_VecFP,
604 [(set f64:$XT, (PPCfctiwz f64:$XB))]>;
605 let isCodeGenOnly = 1 in
606 def XSCVDPSXWSs : XX2Form<60, 88,
607 (outs vssrc:$XT), (ins vssrc:$XB),
608 "xscvdpsxws $XT, $XB", IIC_VecFP,
609 [(set f32:$XT, (PPCfctiwz f32:$XB))]>;
610 def XSCVDPUXDS : XX2Form<60, 328,
611 (outs vsfrc:$XT), (ins vsfrc:$XB),
612 "xscvdpuxds $XT, $XB", IIC_VecFP,
613 [(set f64:$XT, (PPCfctiduz f64:$XB))]>;
614 let isCodeGenOnly = 1 in
615 def XSCVDPUXDSs : XX2Form<60, 328,
616 (outs vssrc:$XT), (ins vssrc:$XB),
617 "xscvdpuxds $XT, $XB", IIC_VecFP,
618 [(set f32:$XT, (PPCfctiduz f32:$XB))]>;
619 def XSCVDPUXWS : XX2Form<60, 72,
620 (outs vsfrc:$XT), (ins vsfrc:$XB),
621 "xscvdpuxws $XT, $XB", IIC_VecFP,
622 [(set f64:$XT, (PPCfctiwuz f64:$XB))]>;
623 let isCodeGenOnly = 1 in
624 def XSCVDPUXWSs : XX2Form<60, 72,
625 (outs vssrc:$XT), (ins vssrc:$XB),
626 "xscvdpuxws $XT, $XB", IIC_VecFP,
627 [(set f32:$XT, (PPCfctiwuz f32:$XB))]>;
628 def XSCVSPDP : XX2Form<60, 329,
629 (outs vsfrc:$XT), (ins vsfrc:$XB),
630 "xscvspdp $XT, $XB", IIC_VecFP, []>;
631 def XSCVSXDDP : XX2Form<60, 376,
632 (outs vsfrc:$XT), (ins vsfrc:$XB),
633 "xscvsxddp $XT, $XB", IIC_VecFP,
634 [(set f64:$XT, (PPCfcfid f64:$XB))]>;
635 def XSCVUXDDP : XX2Form<60, 360,
636 (outs vsfrc:$XT), (ins vsfrc:$XB),
637 "xscvuxddp $XT, $XB", IIC_VecFP,
638 [(set f64:$XT, (PPCfcfidu f64:$XB))]>;
640 def XVCVDPSP : XX2Form<60, 393,
641 (outs vsrc:$XT), (ins vsrc:$XB),
642 "xvcvdpsp $XT, $XB", IIC_VecFP,
643 [(set v4f32:$XT, (int_ppc_vsx_xvcvdpsp v2f64:$XB))]>;
644 def XVCVDPSXDS : XX2Form<60, 472,
645 (outs vsrc:$XT), (ins vsrc:$XB),
646 "xvcvdpsxds $XT, $XB", IIC_VecFP,
647 [(set v2i64:$XT, (fp_to_sint v2f64:$XB))]>;
648 def XVCVDPSXWS : XX2Form<60, 216,
649 (outs vsrc:$XT), (ins vsrc:$XB),
650 "xvcvdpsxws $XT, $XB", IIC_VecFP,
651 [(set v4i32:$XT, (int_ppc_vsx_xvcvdpsxws v2f64:$XB))]>;
652 def XVCVDPUXDS : XX2Form<60, 456,
653 (outs vsrc:$XT), (ins vsrc:$XB),
654 "xvcvdpuxds $XT, $XB", IIC_VecFP,
655 [(set v2i64:$XT, (fp_to_uint v2f64:$XB))]>;
656 def XVCVDPUXWS : XX2Form<60, 200,
657 (outs vsrc:$XT), (ins vsrc:$XB),
658 "xvcvdpuxws $XT, $XB", IIC_VecFP,
659 [(set v4i32:$XT, (int_ppc_vsx_xvcvdpuxws v2f64:$XB))]>;
661 def XVCVSPDP : XX2Form<60, 457,
662 (outs vsrc:$XT), (ins vsrc:$XB),
663 "xvcvspdp $XT, $XB", IIC_VecFP,
664 [(set v2f64:$XT, (int_ppc_vsx_xvcvspdp v4f32:$XB))]>;
665 def XVCVSPSXDS : XX2Form<60, 408,
666 (outs vsrc:$XT), (ins vsrc:$XB),
667 "xvcvspsxds $XT, $XB", IIC_VecFP, []>;
668 def XVCVSPSXWS : XX2Form<60, 152,
669 (outs vsrc:$XT), (ins vsrc:$XB),
670 "xvcvspsxws $XT, $XB", IIC_VecFP,
671 [(set v4i32:$XT, (fp_to_sint v4f32:$XB))]>;
672 def XVCVSPUXDS : XX2Form<60, 392,
673 (outs vsrc:$XT), (ins vsrc:$XB),
674 "xvcvspuxds $XT, $XB", IIC_VecFP, []>;
675 def XVCVSPUXWS : XX2Form<60, 136,
676 (outs vsrc:$XT), (ins vsrc:$XB),
677 "xvcvspuxws $XT, $XB", IIC_VecFP,
678 [(set v4i32:$XT, (fp_to_uint v4f32:$XB))]>;
679 def XVCVSXDDP : XX2Form<60, 504,
680 (outs vsrc:$XT), (ins vsrc:$XB),
681 "xvcvsxddp $XT, $XB", IIC_VecFP,
682 [(set v2f64:$XT, (sint_to_fp v2i64:$XB))]>;
683 def XVCVSXDSP : XX2Form<60, 440,
684 (outs vsrc:$XT), (ins vsrc:$XB),
685 "xvcvsxdsp $XT, $XB", IIC_VecFP,
686 [(set v4f32:$XT, (int_ppc_vsx_xvcvsxdsp v2i64:$XB))]>;
687 def XVCVSXWDP : XX2Form<60, 248,
688 (outs vsrc:$XT), (ins vsrc:$XB),
689 "xvcvsxwdp $XT, $XB", IIC_VecFP,
690 [(set v2f64:$XT, (int_ppc_vsx_xvcvsxwdp v4i32:$XB))]>;
691 def XVCVSXWSP : XX2Form<60, 184,
692 (outs vsrc:$XT), (ins vsrc:$XB),
693 "xvcvsxwsp $XT, $XB", IIC_VecFP,
694 [(set v4f32:$XT, (sint_to_fp v4i32:$XB))]>;
695 def XVCVUXDDP : XX2Form<60, 488,
696 (outs vsrc:$XT), (ins vsrc:$XB),
697 "xvcvuxddp $XT, $XB", IIC_VecFP,
698 [(set v2f64:$XT, (uint_to_fp v2i64:$XB))]>;
699 def XVCVUXDSP : XX2Form<60, 424,
700 (outs vsrc:$XT), (ins vsrc:$XB),
701 "xvcvuxdsp $XT, $XB", IIC_VecFP,
702 [(set v4f32:$XT, (int_ppc_vsx_xvcvuxdsp v2i64:$XB))]>;
703 def XVCVUXWDP : XX2Form<60, 232,
704 (outs vsrc:$XT), (ins vsrc:$XB),
705 "xvcvuxwdp $XT, $XB", IIC_VecFP,
706 [(set v2f64:$XT, (int_ppc_vsx_xvcvuxwdp v4i32:$XB))]>;
707 def XVCVUXWSP : XX2Form<60, 168,
708 (outs vsrc:$XT), (ins vsrc:$XB),
709 "xvcvuxwsp $XT, $XB", IIC_VecFP,
710 [(set v4f32:$XT, (uint_to_fp v4i32:$XB))]>;
712 // Rounding Instructions
713 def XSRDPI : XX2Form<60, 73,
714 (outs vsfrc:$XT), (ins vsfrc:$XB),
715 "xsrdpi $XT, $XB", IIC_VecFP,
716 [(set f64:$XT, (fround f64:$XB))]>;
717 def XSRDPIC : XX2Form<60, 107,
718 (outs vsfrc:$XT), (ins vsfrc:$XB),
719 "xsrdpic $XT, $XB", IIC_VecFP,
720 [(set f64:$XT, (fnearbyint f64:$XB))]>;
721 def XSRDPIM : XX2Form<60, 121,
722 (outs vsfrc:$XT), (ins vsfrc:$XB),
723 "xsrdpim $XT, $XB", IIC_VecFP,
724 [(set f64:$XT, (ffloor f64:$XB))]>;
725 def XSRDPIP : XX2Form<60, 105,
726 (outs vsfrc:$XT), (ins vsfrc:$XB),
727 "xsrdpip $XT, $XB", IIC_VecFP,
728 [(set f64:$XT, (fceil f64:$XB))]>;
729 def XSRDPIZ : XX2Form<60, 89,
730 (outs vsfrc:$XT), (ins vsfrc:$XB),
731 "xsrdpiz $XT, $XB", IIC_VecFP,
732 [(set f64:$XT, (ftrunc f64:$XB))]>;
734 def XVRDPI : XX2Form<60, 201,
735 (outs vsrc:$XT), (ins vsrc:$XB),
736 "xvrdpi $XT, $XB", IIC_VecFP,
737 [(set v2f64:$XT, (fround v2f64:$XB))]>;
738 def XVRDPIC : XX2Form<60, 235,
739 (outs vsrc:$XT), (ins vsrc:$XB),
740 "xvrdpic $XT, $XB", IIC_VecFP,
741 [(set v2f64:$XT, (fnearbyint v2f64:$XB))]>;
742 def XVRDPIM : XX2Form<60, 249,
743 (outs vsrc:$XT), (ins vsrc:$XB),
744 "xvrdpim $XT, $XB", IIC_VecFP,
745 [(set v2f64:$XT, (ffloor v2f64:$XB))]>;
746 def XVRDPIP : XX2Form<60, 233,
747 (outs vsrc:$XT), (ins vsrc:$XB),
748 "xvrdpip $XT, $XB", IIC_VecFP,
749 [(set v2f64:$XT, (fceil v2f64:$XB))]>;
750 def XVRDPIZ : XX2Form<60, 217,
751 (outs vsrc:$XT), (ins vsrc:$XB),
752 "xvrdpiz $XT, $XB", IIC_VecFP,
753 [(set v2f64:$XT, (ftrunc v2f64:$XB))]>;
755 def XVRSPI : XX2Form<60, 137,
756 (outs vsrc:$XT), (ins vsrc:$XB),
757 "xvrspi $XT, $XB", IIC_VecFP,
758 [(set v4f32:$XT, (fround v4f32:$XB))]>;
759 def XVRSPIC : XX2Form<60, 171,
760 (outs vsrc:$XT), (ins vsrc:$XB),
761 "xvrspic $XT, $XB", IIC_VecFP,
762 [(set v4f32:$XT, (fnearbyint v4f32:$XB))]>;
763 def XVRSPIM : XX2Form<60, 185,
764 (outs vsrc:$XT), (ins vsrc:$XB),
765 "xvrspim $XT, $XB", IIC_VecFP,
766 [(set v4f32:$XT, (ffloor v4f32:$XB))]>;
767 def XVRSPIP : XX2Form<60, 169,
768 (outs vsrc:$XT), (ins vsrc:$XB),
769 "xvrspip $XT, $XB", IIC_VecFP,
770 [(set v4f32:$XT, (fceil v4f32:$XB))]>;
771 def XVRSPIZ : XX2Form<60, 153,
772 (outs vsrc:$XT), (ins vsrc:$XB),
773 "xvrspiz $XT, $XB", IIC_VecFP,
774 [(set v4f32:$XT, (ftrunc v4f32:$XB))]>;
776 // Max/Min Instructions
777 let isCommutable = 1 in {
778 def XSMAXDP : XX3Form<60, 160,
779 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
780 "xsmaxdp $XT, $XA, $XB", IIC_VecFP,
782 (int_ppc_vsx_xsmaxdp vsfrc:$XA, vsfrc:$XB))]>;
783 def XSMINDP : XX3Form<60, 168,
784 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
785 "xsmindp $XT, $XA, $XB", IIC_VecFP,
787 (int_ppc_vsx_xsmindp vsfrc:$XA, vsfrc:$XB))]>;
789 def XVMAXDP : XX3Form<60, 224,
790 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
791 "xvmaxdp $XT, $XA, $XB", IIC_VecFP,
793 (int_ppc_vsx_xvmaxdp vsrc:$XA, vsrc:$XB))]>;
794 def XVMINDP : XX3Form<60, 232,
795 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
796 "xvmindp $XT, $XA, $XB", IIC_VecFP,
798 (int_ppc_vsx_xvmindp vsrc:$XA, vsrc:$XB))]>;
800 def XVMAXSP : XX3Form<60, 192,
801 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
802 "xvmaxsp $XT, $XA, $XB", IIC_VecFP,
804 (int_ppc_vsx_xvmaxsp vsrc:$XA, vsrc:$XB))]>;
805 def XVMINSP : XX3Form<60, 200,
806 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
807 "xvminsp $XT, $XA, $XB", IIC_VecFP,
809 (int_ppc_vsx_xvminsp vsrc:$XA, vsrc:$XB))]>;
813 // Logical Instructions
814 let isCommutable = 1 in
815 def XXLAND : XX3Form<60, 130,
816 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
817 "xxland $XT, $XA, $XB", IIC_VecGeneral,
818 [(set v4i32:$XT, (and v4i32:$XA, v4i32:$XB))]>;
819 def XXLANDC : XX3Form<60, 138,
820 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
821 "xxlandc $XT, $XA, $XB", IIC_VecGeneral,
822 [(set v4i32:$XT, (and v4i32:$XA,
823 (vnot_ppc v4i32:$XB)))]>;
824 let isCommutable = 1 in {
825 def XXLNOR : XX3Form<60, 162,
826 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
827 "xxlnor $XT, $XA, $XB", IIC_VecGeneral,
828 [(set v4i32:$XT, (vnot_ppc (or v4i32:$XA,
830 def XXLOR : XX3Form<60, 146,
831 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
832 "xxlor $XT, $XA, $XB", IIC_VecGeneral,
833 [(set v4i32:$XT, (or v4i32:$XA, v4i32:$XB))]>;
834 let isCodeGenOnly = 1 in
835 def XXLORf: XX3Form<60, 146,
836 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
837 "xxlor $XT, $XA, $XB", IIC_VecGeneral, []>;
838 def XXLXOR : XX3Form<60, 154,
839 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
840 "xxlxor $XT, $XA, $XB", IIC_VecGeneral,
841 [(set v4i32:$XT, (xor v4i32:$XA, v4i32:$XB))]>;
843 let isCodeGenOnly = 1 in
844 def XXLXORz : XX3Form_Zero<60, 154, (outs vsrc:$XT), (ins),
845 "xxlxor $XT, $XT, $XT", IIC_VecGeneral,
846 [(set v4i32:$XT, (v4i32 immAllZerosV))]>;
848 let isCodeGenOnly = 1 in {
849 def XXLXORdpz : XX3Form_SetZero<60, 154,
850 (outs vsfrc:$XT), (ins),
851 "xxlxor $XT, $XT, $XT", IIC_VecGeneral,
852 [(set f64:$XT, (fpimm0))]>;
853 def XXLXORspz : XX3Form_SetZero<60, 154,
854 (outs vssrc:$XT), (ins),
855 "xxlxor $XT, $XT, $XT", IIC_VecGeneral,
856 [(set f32:$XT, (fpimm0))]>;
859 // Permutation Instructions
860 def XXMRGHW : XX3Form<60, 18,
861 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
862 "xxmrghw $XT, $XA, $XB", IIC_VecPerm, []>;
863 def XXMRGLW : XX3Form<60, 50,
864 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
865 "xxmrglw $XT, $XA, $XB", IIC_VecPerm, []>;
867 def XXPERMDI : XX3Form_2<60, 10,
868 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB, u2imm:$DM),
869 "xxpermdi $XT, $XA, $XB, $DM", IIC_VecPerm,
870 [(set v2i64:$XT, (PPCxxpermdi v2i64:$XA, v2i64:$XB,
872 let isCodeGenOnly = 1 in
873 def XXPERMDIs : XX3Form_2s<60, 10, (outs vsrc:$XT), (ins vsfrc:$XA, u2imm:$DM),
874 "xxpermdi $XT, $XA, $XA, $DM", IIC_VecPerm, []>;
875 def XXSEL : XX4Form<60, 3,
876 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB, vsrc:$XC),
877 "xxsel $XT, $XA, $XB, $XC", IIC_VecPerm, []>;
879 def XXSLDWI : XX3Form_2<60, 2,
880 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB, u2imm:$SHW),
881 "xxsldwi $XT, $XA, $XB, $SHW", IIC_VecPerm,
882 [(set v4i32:$XT, (PPCvecshl v4i32:$XA, v4i32:$XB,
883 imm32SExt16:$SHW))]>;
885 let isCodeGenOnly = 1 in
886 def XXSLDWIs : XX3Form_2s<60, 2,
887 (outs vsrc:$XT), (ins vsfrc:$XA, u2imm:$SHW),
888 "xxsldwi $XT, $XA, $XA, $SHW", IIC_VecPerm, []>;
890 def XXSPLTW : XX2Form_2<60, 164,
891 (outs vsrc:$XT), (ins vsrc:$XB, u2imm:$UIM),
892 "xxspltw $XT, $XB, $UIM", IIC_VecPerm,
894 (PPCxxsplt v4i32:$XB, imm32SExt16:$UIM))]>;
895 let isCodeGenOnly = 1 in
896 def XXSPLTWs : XX2Form_2<60, 164,
897 (outs vsrc:$XT), (ins vfrc:$XB, u2imm:$UIM),
898 "xxspltw $XT, $XB, $UIM", IIC_VecPerm, []>;
903 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
904 // instruction selection into a branch sequence.
905 let PPC970_Single = 1 in {
907 def SELECT_CC_VSRC: PPCCustomInserterPseudo<(outs vsrc:$dst),
908 (ins crrc:$cond, vsrc:$T, vsrc:$F, i32imm:$BROPC),
911 def SELECT_VSRC: PPCCustomInserterPseudo<(outs vsrc:$dst),
912 (ins crbitrc:$cond, vsrc:$T, vsrc:$F),
915 (select i1:$cond, v2f64:$T, v2f64:$F))]>;
916 def SELECT_CC_VSFRC: PPCCustomInserterPseudo<(outs f8rc:$dst),
917 (ins crrc:$cond, f8rc:$T, f8rc:$F,
918 i32imm:$BROPC), "#SELECT_CC_VSFRC",
920 def SELECT_VSFRC: PPCCustomInserterPseudo<(outs f8rc:$dst),
921 (ins crbitrc:$cond, f8rc:$T, f8rc:$F),
924 (select i1:$cond, f64:$T, f64:$F))]>;
925 def SELECT_CC_VSSRC: PPCCustomInserterPseudo<(outs f4rc:$dst),
926 (ins crrc:$cond, f4rc:$T, f4rc:$F,
927 i32imm:$BROPC), "#SELECT_CC_VSSRC",
929 def SELECT_VSSRC: PPCCustomInserterPseudo<(outs f4rc:$dst),
930 (ins crbitrc:$cond, f4rc:$T, f4rc:$F),
933 (select i1:$cond, f32:$T, f32:$F))]>;
937 def : InstAlias<"xvmovdp $XT, $XB",
938 (XVCPSGNDP vsrc:$XT, vsrc:$XB, vsrc:$XB)>;
939 def : InstAlias<"xvmovsp $XT, $XB",
940 (XVCPSGNSP vsrc:$XT, vsrc:$XB, vsrc:$XB)>;
942 def : InstAlias<"xxspltd $XT, $XB, 0",
943 (XXPERMDI vsrc:$XT, vsrc:$XB, vsrc:$XB, 0)>;
944 def : InstAlias<"xxspltd $XT, $XB, 1",
945 (XXPERMDI vsrc:$XT, vsrc:$XB, vsrc:$XB, 3)>;
946 def : InstAlias<"xxmrghd $XT, $XA, $XB",
947 (XXPERMDI vsrc:$XT, vsrc:$XA, vsrc:$XB, 0)>;
948 def : InstAlias<"xxmrgld $XT, $XA, $XB",
949 (XXPERMDI vsrc:$XT, vsrc:$XA, vsrc:$XB, 3)>;
950 def : InstAlias<"xxswapd $XT, $XB",
951 (XXPERMDI vsrc:$XT, vsrc:$XB, vsrc:$XB, 2)>;
952 def : InstAlias<"xxspltd $XT, $XB, 0",
953 (XXPERMDIs vsrc:$XT, vsfrc:$XB, 0)>;
954 def : InstAlias<"xxspltd $XT, $XB, 1",
955 (XXPERMDIs vsrc:$XT, vsfrc:$XB, 3)>;
956 def : InstAlias<"xxswapd $XT, $XB",
957 (XXPERMDIs vsrc:$XT, vsfrc:$XB, 2)>;
959 let AddedComplexity = 400 in { // Prefer VSX patterns over non-VSX patterns.
961 def : Pat<(v4i32 (vnot_ppc v4i32:$A)),
962 (v4i32 (XXLNOR $A, $A))>;
963 let Predicates = [IsBigEndian] in {
964 def : Pat<(v2f64 (scalar_to_vector f64:$A)),
965 (v2f64 (SUBREG_TO_REG (i64 1), $A, sub_64))>;
967 def : Pat<(f64 (extractelt v2f64:$S, 0)),
968 (f64 (EXTRACT_SUBREG $S, sub_64))>;
969 def : Pat<(f64 (extractelt v2f64:$S, 1)),
970 (f64 (EXTRACT_SUBREG (XXPERMDI $S, $S, 2), sub_64))>;
973 let Predicates = [IsLittleEndian] in {
974 def : Pat<(v2f64 (scalar_to_vector f64:$A)),
975 (v2f64 (XXPERMDI (SUBREG_TO_REG (i64 1), $A, sub_64),
976 (SUBREG_TO_REG (i64 1), $A, sub_64), 0))>;
978 def : Pat<(f64 (extractelt v2f64:$S, 0)),
979 (f64 (EXTRACT_SUBREG (XXPERMDI $S, $S, 2), sub_64))>;
980 def : Pat<(f64 (extractelt v2f64:$S, 1)),
981 (f64 (EXTRACT_SUBREG $S, sub_64))>;
984 // Additional fnmsub patterns: -a*c + b == -(a*c - b)
985 def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B),
986 (XSNMSUBADP $B, $C, $A)>;
987 def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B),
988 (XSNMSUBADP $B, $C, $A)>;
990 def : Pat<(fma (fneg v2f64:$A), v2f64:$C, v2f64:$B),
991 (XVNMSUBADP $B, $C, $A)>;
992 def : Pat<(fma v2f64:$A, (fneg v2f64:$C), v2f64:$B),
993 (XVNMSUBADP $B, $C, $A)>;
995 def : Pat<(fma (fneg v4f32:$A), v4f32:$C, v4f32:$B),
996 (XVNMSUBASP $B, $C, $A)>;
997 def : Pat<(fma v4f32:$A, (fneg v4f32:$C), v4f32:$B),
998 (XVNMSUBASP $B, $C, $A)>;
1000 def : Pat<(v2f64 (bitconvert v4f32:$A)),
1001 (COPY_TO_REGCLASS $A, VSRC)>;
1002 def : Pat<(v2f64 (bitconvert v4i32:$A)),
1003 (COPY_TO_REGCLASS $A, VSRC)>;
1004 def : Pat<(v2f64 (bitconvert v8i16:$A)),
1005 (COPY_TO_REGCLASS $A, VSRC)>;
1006 def : Pat<(v2f64 (bitconvert v16i8:$A)),
1007 (COPY_TO_REGCLASS $A, VSRC)>;
1009 def : Pat<(v4f32 (bitconvert v2f64:$A)),
1010 (COPY_TO_REGCLASS $A, VRRC)>;
1011 def : Pat<(v4i32 (bitconvert v2f64:$A)),
1012 (COPY_TO_REGCLASS $A, VRRC)>;
1013 def : Pat<(v8i16 (bitconvert v2f64:$A)),
1014 (COPY_TO_REGCLASS $A, VRRC)>;
1015 def : Pat<(v16i8 (bitconvert v2f64:$A)),
1016 (COPY_TO_REGCLASS $A, VRRC)>;
1018 def : Pat<(v2i64 (bitconvert v4f32:$A)),
1019 (COPY_TO_REGCLASS $A, VSRC)>;
1020 def : Pat<(v2i64 (bitconvert v4i32:$A)),
1021 (COPY_TO_REGCLASS $A, VSRC)>;
1022 def : Pat<(v2i64 (bitconvert v8i16:$A)),
1023 (COPY_TO_REGCLASS $A, VSRC)>;
1024 def : Pat<(v2i64 (bitconvert v16i8:$A)),
1025 (COPY_TO_REGCLASS $A, VSRC)>;
1027 def : Pat<(v4f32 (bitconvert v2i64:$A)),
1028 (COPY_TO_REGCLASS $A, VRRC)>;
1029 def : Pat<(v4i32 (bitconvert v2i64:$A)),
1030 (COPY_TO_REGCLASS $A, VRRC)>;
1031 def : Pat<(v8i16 (bitconvert v2i64:$A)),
1032 (COPY_TO_REGCLASS $A, VRRC)>;
1033 def : Pat<(v16i8 (bitconvert v2i64:$A)),
1034 (COPY_TO_REGCLASS $A, VRRC)>;
1036 def : Pat<(v2f64 (bitconvert v2i64:$A)),
1037 (COPY_TO_REGCLASS $A, VRRC)>;
1038 def : Pat<(v2i64 (bitconvert v2f64:$A)),
1039 (COPY_TO_REGCLASS $A, VRRC)>;
1041 def : Pat<(v2f64 (bitconvert v1i128:$A)),
1042 (COPY_TO_REGCLASS $A, VRRC)>;
1043 def : Pat<(v1i128 (bitconvert v2f64:$A)),
1044 (COPY_TO_REGCLASS $A, VRRC)>;
1046 def : Pat<(v2i64 (bitconvert f128:$A)),
1047 (COPY_TO_REGCLASS $A, VRRC)>;
1048 def : Pat<(v4i32 (bitconvert f128:$A)),
1049 (COPY_TO_REGCLASS $A, VRRC)>;
1050 def : Pat<(v8i16 (bitconvert f128:$A)),
1051 (COPY_TO_REGCLASS $A, VRRC)>;
1052 def : Pat<(v16i8 (bitconvert f128:$A)),
1053 (COPY_TO_REGCLASS $A, VRRC)>;
1055 def : Pat<(v2f64 (PPCsvec2fp v4i32:$C, 0)),
1056 (v2f64 (XVCVSXWDP (v2i64 (XXMRGHW $C, $C))))>;
1057 def : Pat<(v2f64 (PPCsvec2fp v4i32:$C, 1)),
1058 (v2f64 (XVCVSXWDP (v2i64 (XXMRGLW $C, $C))))>;
1060 def : Pat<(v2f64 (PPCuvec2fp v4i32:$C, 0)),
1061 (v2f64 (XVCVUXWDP (v2i64 (XXMRGHW $C, $C))))>;
1062 def : Pat<(v2f64 (PPCuvec2fp v4i32:$C, 1)),
1063 (v2f64 (XVCVUXWDP (v2i64 (XXMRGLW $C, $C))))>;
1066 let Predicates = [HasVSX, HasOnlySwappingMemOps] in {
1067 def : Pat<(v2f64 (PPClxvd2x xoaddr:$src)), (LXVD2X xoaddr:$src)>;
1070 def : Pat<(int_ppc_vsx_stxvd2x v2f64:$rS, xoaddr:$dst),
1071 (STXVD2X $rS, xoaddr:$dst)>;
1072 def : Pat<(PPCstxvd2x v2f64:$rS, xoaddr:$dst), (STXVD2X $rS, xoaddr:$dst)>;
1074 let Predicates = [IsBigEndian, HasVSX, HasOnlySwappingMemOps] in {
1075 def : Pat<(v2f64 (load xoaddr:$src)), (LXVD2X xoaddr:$src)>;
1076 def : Pat<(v2i64 (load xoaddr:$src)), (LXVD2X xoaddr:$src)>;
1077 def : Pat<(v4i32 (load xoaddr:$src)), (LXVW4X xoaddr:$src)>;
1078 def : Pat<(v4i32 (int_ppc_vsx_lxvw4x xoaddr:$src)), (LXVW4X xoaddr:$src)>;
1079 def : Pat<(store v2f64:$rS, xoaddr:$dst), (STXVD2X $rS, xoaddr:$dst)>;
1080 def : Pat<(store v2i64:$rS, xoaddr:$dst), (STXVD2X $rS, xoaddr:$dst)>;
1081 def : Pat<(store v4i32:$XT, xoaddr:$dst), (STXVW4X $XT, xoaddr:$dst)>;
1082 def : Pat<(int_ppc_vsx_stxvw4x v4i32:$rS, xoaddr:$dst),
1083 (STXVW4X $rS, xoaddr:$dst)>;
1087 def : Pat<(v2f64 (PPCxxswapd v2f64:$src)), (XXPERMDI $src, $src, 2)>;
1088 def : Pat<(v2i64 (PPCxxswapd v2i64:$src)), (XXPERMDI $src, $src, 2)>;
1089 def : Pat<(v4f32 (PPCxxswapd v4f32:$src)), (XXPERMDI $src, $src, 2)>;
1090 def : Pat<(v4i32 (PPCxxswapd v4i32:$src)), (XXPERMDI $src, $src, 2)>;
1091 def : Pat<(v2f64 (PPCswapNoChain v2f64:$src)), (XXPERMDI $src, $src, 2)>;
1093 // PPCvecshl XT, XA, XA, 2 can be selected to both XXSLDWI XT,XA,XA,2 and
1094 // XXSWAPD XT,XA (i.e. XXPERMDI XT,XA,XA,2), the later one is more profitable.
1095 def : Pat<(v4i32 (PPCvecshl v4i32:$src, v4i32:$src, 2)), (XXPERMDI $src, $src, 2)>;
1098 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETLT)),
1099 (SELECT_VSRC (CRANDC $lhs, $rhs), $tval, $fval)>;
1100 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETULT)),
1101 (SELECT_VSRC (CRANDC $rhs, $lhs), $tval, $fval)>;
1102 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETLE)),
1103 (SELECT_VSRC (CRORC $lhs, $rhs), $tval, $fval)>;
1104 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETULE)),
1105 (SELECT_VSRC (CRORC $rhs, $lhs), $tval, $fval)>;
1106 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETEQ)),
1107 (SELECT_VSRC (CREQV $lhs, $rhs), $tval, $fval)>;
1108 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETGE)),
1109 (SELECT_VSRC (CRORC $rhs, $lhs), $tval, $fval)>;
1110 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETUGE)),
1111 (SELECT_VSRC (CRORC $lhs, $rhs), $tval, $fval)>;
1112 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETGT)),
1113 (SELECT_VSRC (CRANDC $rhs, $lhs), $tval, $fval)>;
1114 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETUGT)),
1115 (SELECT_VSRC (CRANDC $lhs, $rhs), $tval, $fval)>;
1116 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETNE)),
1117 (SELECT_VSRC (CRXOR $lhs, $rhs), $tval, $fval)>;
1119 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
1120 (SELECT_VSFRC (CRANDC $lhs, $rhs), $tval, $fval)>;
1121 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
1122 (SELECT_VSFRC (CRANDC $rhs, $lhs), $tval, $fval)>;
1123 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
1124 (SELECT_VSFRC (CRORC $lhs, $rhs), $tval, $fval)>;
1125 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
1126 (SELECT_VSFRC (CRORC $rhs, $lhs), $tval, $fval)>;
1127 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
1128 (SELECT_VSFRC (CREQV $lhs, $rhs), $tval, $fval)>;
1129 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
1130 (SELECT_VSFRC (CRORC $rhs, $lhs), $tval, $fval)>;
1131 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
1132 (SELECT_VSFRC (CRORC $lhs, $rhs), $tval, $fval)>;
1133 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
1134 (SELECT_VSFRC (CRANDC $rhs, $lhs), $tval, $fval)>;
1135 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
1136 (SELECT_VSFRC (CRANDC $lhs, $rhs), $tval, $fval)>;
1137 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
1138 (SELECT_VSFRC (CRXOR $lhs, $rhs), $tval, $fval)>;
1141 def : Pat<(int_ppc_vsx_xvdivsp v4f32:$A, v4f32:$B),
1143 def : Pat<(int_ppc_vsx_xvdivdp v2f64:$A, v2f64:$B),
1146 // Reciprocal estimate
1147 def : Pat<(int_ppc_vsx_xvresp v4f32:$A),
1149 def : Pat<(int_ppc_vsx_xvredp v2f64:$A),
1152 // Recip. square root estimate
1153 def : Pat<(int_ppc_vsx_xvrsqrtesp v4f32:$A),
1155 def : Pat<(int_ppc_vsx_xvrsqrtedp v2f64:$A),
1159 def : Pat<(v16i8 (vselect v16i8:$vA, v16i8:$vB, v16i8:$vC)),
1161 (XXSEL (COPY_TO_REGCLASS $vC, VSRC),
1162 (COPY_TO_REGCLASS $vB, VSRC),
1163 (COPY_TO_REGCLASS $vA, VSRC)), VRRC)>;
1164 def : Pat<(v8i16 (vselect v8i16:$vA, v8i16:$vB, v8i16:$vC)),
1166 (XXSEL (COPY_TO_REGCLASS $vC, VSRC),
1167 (COPY_TO_REGCLASS $vB, VSRC),
1168 (COPY_TO_REGCLASS $vA, VSRC)), VRRC)>;
1169 def : Pat<(vselect v4i32:$vA, v4i32:$vB, v4i32:$vC),
1170 (XXSEL $vC, $vB, $vA)>;
1171 def : Pat<(vselect v2i64:$vA, v2i64:$vB, v2i64:$vC),
1172 (XXSEL $vC, $vB, $vA)>;
1173 def : Pat<(vselect v4i32:$vA, v4f32:$vB, v4f32:$vC),
1174 (XXSEL $vC, $vB, $vA)>;
1175 def : Pat<(vselect v2i64:$vA, v2f64:$vB, v2f64:$vC),
1176 (XXSEL $vC, $vB, $vA)>;
1178 let Predicates = [IsLittleEndian] in {
1179 def : Pat<(f64 (PPCfcfid (PPCmtvsra (i64 (vector_extract v2i64:$S, 0))))),
1180 (f64 (XSCVSXDDP (COPY_TO_REGCLASS (XXPERMDI $S, $S, 2), VSFRC)))>;
1181 def : Pat<(f64 (PPCfcfid (PPCmtvsra (i64 (vector_extract v2i64:$S, 1))))),
1182 (f64 (XSCVSXDDP (COPY_TO_REGCLASS (f64 (COPY_TO_REGCLASS $S, VSRC)), VSFRC)))>;
1183 def : Pat<(f64 (PPCfcfidu (PPCmtvsra (i64 (vector_extract v2i64:$S, 0))))),
1184 (f64 (XSCVUXDDP (COPY_TO_REGCLASS (XXPERMDI $S, $S, 2), VSFRC)))>;
1185 def : Pat<(f64 (PPCfcfidu (PPCmtvsra (i64 (vector_extract v2i64:$S, 1))))),
1186 (f64 (XSCVUXDDP (COPY_TO_REGCLASS (f64 (COPY_TO_REGCLASS $S, VSRC)), VSFRC)))>;
1189 let Predicates = [IsBigEndian] in {
1190 def : Pat<(f64 (PPCfcfid (PPCmtvsra (i64 (vector_extract v2i64:$S, 0))))),
1191 (f64 (XSCVSXDDP (COPY_TO_REGCLASS $S, VSFRC)))>;
1192 def : Pat<(f64 (PPCfcfid (PPCmtvsra (i64 (vector_extract v2i64:$S, 1))))),
1193 (f64 (XSCVSXDDP (COPY_TO_REGCLASS (XXPERMDI $S, $S, 2), VSFRC)))>;
1194 def : Pat<(f64 (PPCfcfidu (PPCmtvsra (i64 (vector_extract v2i64:$S, 0))))),
1195 (f64 (XSCVUXDDP (COPY_TO_REGCLASS $S, VSFRC)))>;
1196 def : Pat<(f64 (PPCfcfidu (PPCmtvsra (i64 (vector_extract v2i64:$S, 1))))),
1197 (f64 (XSCVUXDDP (COPY_TO_REGCLASS (XXPERMDI $S, $S, 2), VSFRC)))>;
1200 } // AddedComplexity
1204 dag Li8 = (i32 (extloadi8 xoaddr:$src));
1205 dag ZELi8 = (i32 (zextloadi8 xoaddr:$src));
1206 dag ZELi8i64 = (i64 (zextloadi8 xoaddr:$src));
1207 dag SELi8 = (i32 (sext_inreg (extloadi8 xoaddr:$src), i8));
1208 dag SELi8i64 = (i64 (sext_inreg (extloadi8 xoaddr:$src), i8));
1210 dag Li16 = (i32 (extloadi16 xoaddr:$src));
1211 dag ZELi16 = (i32 (zextloadi16 xoaddr:$src));
1212 dag ZELi16i64 = (i64 (zextloadi16 xoaddr:$src));
1213 dag SELi16 = (i32 (sextloadi16 xoaddr:$src));
1214 dag SELi16i64 = (i64 (sextloadi16 xoaddr:$src));
1216 dag Li32 = (i32 (load xoaddr:$src));
1219 def DWToSPExtractConv {
1220 dag El0US1 = (f32 (PPCfcfidus
1221 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S1, 0))))));
1222 dag El1US1 = (f32 (PPCfcfidus
1223 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S1, 1))))));
1224 dag El0US2 = (f32 (PPCfcfidus
1225 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S2, 0))))));
1226 dag El1US2 = (f32 (PPCfcfidus
1227 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S2, 1))))));
1228 dag El0SS1 = (f32 (PPCfcfids
1229 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S1, 0))))));
1230 dag El1SS1 = (f32 (PPCfcfids
1231 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S1, 1))))));
1232 dag El0SS2 = (f32 (PPCfcfids
1233 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S2, 0))))));
1234 dag El1SS2 = (f32 (PPCfcfids
1235 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S2, 1))))));
1236 dag BVU = (v4f32 (build_vector El0US1, El1US1, El0US2, El1US2));
1237 dag BVS = (v4f32 (build_vector El0SS1, El1SS1, El0SS2, El1SS2));
1240 // The following VSX instructions were introduced in Power ISA 2.07
1241 /* FIXME: if the operands are v2i64, these patterns will not match.
1242 we should define new patterns or otherwise match the same patterns
1243 when the elements are larger than i32.
1245 def HasP8Vector : Predicate<"PPCSubTarget->hasP8Vector()">;
1246 def HasDirectMove : Predicate<"PPCSubTarget->hasDirectMove()">;
1247 def NoP9Vector : Predicate<"!PPCSubTarget->hasP9Vector()">;
1248 let Predicates = [HasP8Vector] in {
1249 let AddedComplexity = 400 in { // Prefer VSX patterns over non-VSX patterns.
1250 let isCommutable = 1, UseVSXReg = 1 in {
1251 def XXLEQV : XX3Form<60, 186,
1252 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1253 "xxleqv $XT, $XA, $XB", IIC_VecGeneral,
1254 [(set v4i32:$XT, (vnot_ppc (xor v4i32:$XA, v4i32:$XB)))]>;
1255 def XXLNAND : XX3Form<60, 178,
1256 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1257 "xxlnand $XT, $XA, $XB", IIC_VecGeneral,
1258 [(set v4i32:$XT, (vnot_ppc (and v4i32:$XA,
1260 } // isCommutable, UseVSXReg
1262 def : Pat<(int_ppc_vsx_xxleqv v4i32:$A, v4i32:$B),
1265 let UseVSXReg = 1 in {
1266 def XXLORC : XX3Form<60, 170,
1267 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1268 "xxlorc $XT, $XA, $XB", IIC_VecGeneral,
1269 [(set v4i32:$XT, (or v4i32:$XA, (vnot_ppc v4i32:$XB)))]>;
1271 // VSX scalar loads introduced in ISA 2.07
1272 let mayLoad = 1, mayStore = 0 in {
1274 def LXSSPX : XX1Form_memOp<31, 524, (outs vssrc:$XT), (ins memrr:$src),
1275 "lxsspx $XT, $src", IIC_LdStLFD, []>;
1276 def LXSIWAX : XX1Form_memOp<31, 76, (outs vsfrc:$XT), (ins memrr:$src),
1277 "lxsiwax $XT, $src", IIC_LdStLFD, []>;
1278 def LXSIWZX : XX1Form_memOp<31, 12, (outs vsfrc:$XT), (ins memrr:$src),
1279 "lxsiwzx $XT, $src", IIC_LdStLFD, []>;
1281 // Pseudo instruction XFLOADf32 will be expanded to LXSSPX or LFSX later
1283 def XFLOADf32 : PseudoXFormMemOp<(outs vssrc:$XT), (ins memrr:$src),
1285 [(set f32:$XT, (load xoaddr:$src))]>;
1286 // Pseudo instruction LIWAX will be expanded to LXSIWAX or LFIWAX later
1287 def LIWAX : PseudoXFormMemOp<(outs vsfrc:$XT), (ins memrr:$src),
1289 [(set f64:$XT, (PPClfiwax xoaddr:$src))]>;
1290 // Pseudo instruction LIWZX will be expanded to LXSIWZX or LFIWZX later
1291 def LIWZX : PseudoXFormMemOp<(outs vsfrc:$XT), (ins memrr:$src),
1293 [(set f64:$XT, (PPClfiwzx xoaddr:$src))]>;
1296 // VSX scalar stores introduced in ISA 2.07
1297 let mayStore = 1, mayLoad = 0 in {
1299 def STXSSPX : XX1Form_memOp<31, 652, (outs), (ins vssrc:$XT, memrr:$dst),
1300 "stxsspx $XT, $dst", IIC_LdStSTFD, []>;
1301 def STXSIWX : XX1Form_memOp<31, 140, (outs), (ins vsfrc:$XT, memrr:$dst),
1302 "stxsiwx $XT, $dst", IIC_LdStSTFD, []>;
1304 // Pseudo instruction XFSTOREf32 will be expanded to STXSSPX or STFSX later
1306 def XFSTOREf32 : PseudoXFormMemOp<(outs), (ins vssrc:$XT, memrr:$dst),
1308 [(store f32:$XT, xoaddr:$dst)]>;
1309 // Pseudo instruction STIWX will be expanded to STXSIWX or STFIWX later
1310 def STIWX : PseudoXFormMemOp<(outs), (ins vsfrc:$XT, memrr:$dst),
1312 [(PPCstfiwx f64:$XT, xoaddr:$dst)]>;
1316 def : Pat<(f64 (extloadf32 xoaddr:$src)),
1317 (COPY_TO_REGCLASS (XFLOADf32 xoaddr:$src), VSFRC)>;
1318 def : Pat<(f32 (fpround (f64 (extloadf32 xoaddr:$src)))),
1319 (f32 (XFLOADf32 xoaddr:$src))>;
1320 def : Pat<(f64 (fpextend f32:$src)),
1321 (COPY_TO_REGCLASS $src, VSFRC)>;
1323 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
1324 (SELECT_VSSRC (CRANDC $lhs, $rhs), $tval, $fval)>;
1325 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
1326 (SELECT_VSSRC (CRANDC $rhs, $lhs), $tval, $fval)>;
1327 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
1328 (SELECT_VSSRC (CRORC $lhs, $rhs), $tval, $fval)>;
1329 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
1330 (SELECT_VSSRC (CRORC $rhs, $lhs), $tval, $fval)>;
1331 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
1332 (SELECT_VSSRC (CREQV $lhs, $rhs), $tval, $fval)>;
1333 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
1334 (SELECT_VSSRC (CRORC $rhs, $lhs), $tval, $fval)>;
1335 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
1336 (SELECT_VSSRC (CRORC $lhs, $rhs), $tval, $fval)>;
1337 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
1338 (SELECT_VSSRC (CRANDC $rhs, $lhs), $tval, $fval)>;
1339 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
1340 (SELECT_VSSRC (CRANDC $lhs, $rhs), $tval, $fval)>;
1341 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
1342 (SELECT_VSSRC (CRXOR $lhs, $rhs), $tval, $fval)>;
1344 let UseVSXReg = 1 in {
1345 // VSX Elementary Scalar FP arithmetic (SP)
1346 let isCommutable = 1 in {
1347 def XSADDSP : XX3Form<60, 0,
1348 (outs vssrc:$XT), (ins vssrc:$XA, vssrc:$XB),
1349 "xsaddsp $XT, $XA, $XB", IIC_VecFP,
1350 [(set f32:$XT, (fadd f32:$XA, f32:$XB))]>;
1351 def XSMULSP : XX3Form<60, 16,
1352 (outs vssrc:$XT), (ins vssrc:$XA, vssrc:$XB),
1353 "xsmulsp $XT, $XA, $XB", IIC_VecFP,
1354 [(set f32:$XT, (fmul f32:$XA, f32:$XB))]>;
1357 def XSDIVSP : XX3Form<60, 24,
1358 (outs vssrc:$XT), (ins vssrc:$XA, vssrc:$XB),
1359 "xsdivsp $XT, $XA, $XB", IIC_FPDivS,
1360 [(set f32:$XT, (fdiv f32:$XA, f32:$XB))]>;
1361 def XSRESP : XX2Form<60, 26,
1362 (outs vssrc:$XT), (ins vssrc:$XB),
1363 "xsresp $XT, $XB", IIC_VecFP,
1364 [(set f32:$XT, (PPCfre f32:$XB))]>;
1365 def XSRSP : XX2Form<60, 281,
1366 (outs vssrc:$XT), (ins vsfrc:$XB),
1367 "xsrsp $XT, $XB", IIC_VecFP, []>;
1368 def XSSQRTSP : XX2Form<60, 11,
1369 (outs vssrc:$XT), (ins vssrc:$XB),
1370 "xssqrtsp $XT, $XB", IIC_FPSqrtS,
1371 [(set f32:$XT, (fsqrt f32:$XB))]>;
1372 def XSRSQRTESP : XX2Form<60, 10,
1373 (outs vssrc:$XT), (ins vssrc:$XB),
1374 "xsrsqrtesp $XT, $XB", IIC_VecFP,
1375 [(set f32:$XT, (PPCfrsqrte f32:$XB))]>;
1376 def XSSUBSP : XX3Form<60, 8,
1377 (outs vssrc:$XT), (ins vssrc:$XA, vssrc:$XB),
1378 "xssubsp $XT, $XA, $XB", IIC_VecFP,
1379 [(set f32:$XT, (fsub f32:$XA, f32:$XB))]>;
1382 let BaseName = "XSMADDASP" in {
1383 let isCommutable = 1 in
1384 def XSMADDASP : XX3Form<60, 1,
1386 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1387 "xsmaddasp $XT, $XA, $XB", IIC_VecFP,
1388 [(set f32:$XT, (fma f32:$XA, f32:$XB, f32:$XTi))]>,
1389 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1391 let IsVSXFMAAlt = 1 in
1392 def XSMADDMSP : XX3Form<60, 9,
1394 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1395 "xsmaddmsp $XT, $XA, $XB", IIC_VecFP, []>,
1396 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1400 let BaseName = "XSMSUBASP" in {
1401 let isCommutable = 1 in
1402 def XSMSUBASP : XX3Form<60, 17,
1404 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1405 "xsmsubasp $XT, $XA, $XB", IIC_VecFP,
1406 [(set f32:$XT, (fma f32:$XA, f32:$XB,
1407 (fneg f32:$XTi)))]>,
1408 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1410 let IsVSXFMAAlt = 1 in
1411 def XSMSUBMSP : XX3Form<60, 25,
1413 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1414 "xsmsubmsp $XT, $XA, $XB", IIC_VecFP, []>,
1415 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1419 let BaseName = "XSNMADDASP" in {
1420 let isCommutable = 1 in
1421 def XSNMADDASP : XX3Form<60, 129,
1423 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1424 "xsnmaddasp $XT, $XA, $XB", IIC_VecFP,
1425 [(set f32:$XT, (fneg (fma f32:$XA, f32:$XB,
1427 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1429 let IsVSXFMAAlt = 1 in
1430 def XSNMADDMSP : XX3Form<60, 137,
1432 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1433 "xsnmaddmsp $XT, $XA, $XB", IIC_VecFP, []>,
1434 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1438 let BaseName = "XSNMSUBASP" in {
1439 let isCommutable = 1 in
1440 def XSNMSUBASP : XX3Form<60, 145,
1442 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1443 "xsnmsubasp $XT, $XA, $XB", IIC_VecFP,
1444 [(set f32:$XT, (fneg (fma f32:$XA, f32:$XB,
1445 (fneg f32:$XTi))))]>,
1446 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1448 let IsVSXFMAAlt = 1 in
1449 def XSNMSUBMSP : XX3Form<60, 153,
1451 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1452 "xsnmsubmsp $XT, $XA, $XB", IIC_VecFP, []>,
1453 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1457 // Single Precision Conversions (FP <-> INT)
1458 def XSCVSXDSP : XX2Form<60, 312,
1459 (outs vssrc:$XT), (ins vsfrc:$XB),
1460 "xscvsxdsp $XT, $XB", IIC_VecFP,
1461 [(set f32:$XT, (PPCfcfids f64:$XB))]>;
1462 def XSCVUXDSP : XX2Form<60, 296,
1463 (outs vssrc:$XT), (ins vsfrc:$XB),
1464 "xscvuxdsp $XT, $XB", IIC_VecFP,
1465 [(set f32:$XT, (PPCfcfidus f64:$XB))]>;
1467 // Conversions between vector and scalar single precision
1468 def XSCVDPSPN : XX2Form<60, 267, (outs vsrc:$XT), (ins vssrc:$XB),
1469 "xscvdpspn $XT, $XB", IIC_VecFP, []>;
1470 def XSCVSPDPN : XX2Form<60, 331, (outs vssrc:$XT), (ins vsrc:$XB),
1471 "xscvspdpn $XT, $XB", IIC_VecFP, []>;
1474 let Predicates = [IsLittleEndian] in {
1475 def : Pat<DWToSPExtractConv.El0SS1,
1476 (f32 (XSCVSXDSP (COPY_TO_REGCLASS (XXPERMDI $S1, $S1, 2), VSFRC)))>;
1477 def : Pat<DWToSPExtractConv.El1SS1,
1478 (f32 (XSCVSXDSP (COPY_TO_REGCLASS
1479 (f64 (COPY_TO_REGCLASS $S1, VSRC)), VSFRC)))>;
1480 def : Pat<DWToSPExtractConv.El0US1,
1481 (f32 (XSCVUXDSP (COPY_TO_REGCLASS (XXPERMDI $S1, $S1, 2), VSFRC)))>;
1482 def : Pat<DWToSPExtractConv.El1US1,
1483 (f32 (XSCVUXDSP (COPY_TO_REGCLASS
1484 (f64 (COPY_TO_REGCLASS $S1, VSRC)), VSFRC)))>;
1487 let Predicates = [IsBigEndian] in {
1488 def : Pat<DWToSPExtractConv.El0SS1,
1489 (f32 (XSCVSXDSP (COPY_TO_REGCLASS $S1, VSFRC)))>;
1490 def : Pat<DWToSPExtractConv.El1SS1,
1491 (f32 (XSCVSXDSP (COPY_TO_REGCLASS (XXPERMDI $S1, $S1, 2), VSFRC)))>;
1492 def : Pat<DWToSPExtractConv.El0US1,
1493 (f32 (XSCVUXDSP (COPY_TO_REGCLASS $S1, VSFRC)))>;
1494 def : Pat<DWToSPExtractConv.El1US1,
1495 (f32 (XSCVUXDSP (COPY_TO_REGCLASS (XXPERMDI $S1, $S1, 2), VSFRC)))>;
1498 // Instructions for converting float to i64 feeding a store.
1499 let Predicates = [NoP9Vector] in {
1500 def : Pat<(PPCstore_scal_int_from_vsr
1501 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), xoaddr:$dst, 8),
1502 (STXSDX (XSCVDPSXDS f64:$src), xoaddr:$dst)>;
1503 def : Pat<(PPCstore_scal_int_from_vsr
1504 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), xoaddr:$dst, 8),
1505 (STXSDX (XSCVDPUXDS f64:$src), xoaddr:$dst)>;
1508 // Instructions for converting float to i32 feeding a store.
1509 def : Pat<(PPCstore_scal_int_from_vsr
1510 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), xoaddr:$dst, 4),
1511 (STIWX (XSCVDPSXWS f64:$src), xoaddr:$dst)>;
1512 def : Pat<(PPCstore_scal_int_from_vsr
1513 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), xoaddr:$dst, 4),
1514 (STIWX (XSCVDPUXWS f64:$src), xoaddr:$dst)>;
1516 } // AddedComplexity = 400
1519 let UseVSXReg = 1, AddedComplexity = 400 in {
1520 let Predicates = [HasDirectMove] in {
1521 // VSX direct move instructions
1522 def MFVSRD : XX1_RS6_RD5_XO<31, 51, (outs g8rc:$rA), (ins vsfrc:$XT),
1523 "mfvsrd $rA, $XT", IIC_VecGeneral,
1524 [(set i64:$rA, (PPCmfvsr f64:$XT))]>,
1525 Requires<[In64BitMode]>;
1526 let isCodeGenOnly = 1 in
1527 def MFVRD : XX1_RS6_RD5_XO<31, 51, (outs g8rc:$rA), (ins vrrc:$XT),
1528 "mfvsrd $rA, $XT", IIC_VecGeneral,
1530 Requires<[In64BitMode]>;
1531 def MFVSRWZ : XX1_RS6_RD5_XO<31, 115, (outs gprc:$rA), (ins vsfrc:$XT),
1532 "mfvsrwz $rA, $XT", IIC_VecGeneral,
1533 [(set i32:$rA, (PPCmfvsr f64:$XT))]>;
1534 def MTVSRD : XX1_RS6_RD5_XO<31, 179, (outs vsfrc:$XT), (ins g8rc:$rA),
1535 "mtvsrd $XT, $rA", IIC_VecGeneral,
1536 [(set f64:$XT, (PPCmtvsra i64:$rA))]>,
1537 Requires<[In64BitMode]>;
1538 def MTVSRWA : XX1_RS6_RD5_XO<31, 211, (outs vsfrc:$XT), (ins gprc:$rA),
1539 "mtvsrwa $XT, $rA", IIC_VecGeneral,
1540 [(set f64:$XT, (PPCmtvsra i32:$rA))]>;
1541 def MTVSRWZ : XX1_RS6_RD5_XO<31, 243, (outs vsfrc:$XT), (ins gprc:$rA),
1542 "mtvsrwz $XT, $rA", IIC_VecGeneral,
1543 [(set f64:$XT, (PPCmtvsrz i32:$rA))]>;
1546 let Predicates = [IsISA3_0, HasDirectMove] in {
1547 def MTVSRWS: XX1_RS6_RD5_XO<31, 403, (outs vsrc:$XT), (ins gprc:$rA),
1548 "mtvsrws $XT, $rA", IIC_VecGeneral, []>;
1550 def MTVSRDD: XX1Form<31, 435, (outs vsrc:$XT), (ins g8rc_nox0:$rA, g8rc:$rB),
1551 "mtvsrdd $XT, $rA, $rB", IIC_VecGeneral,
1552 []>, Requires<[In64BitMode]>;
1554 def MFVSRLD: XX1_RS6_RD5_XO<31, 307, (outs g8rc:$rA), (ins vsrc:$XT),
1555 "mfvsrld $rA, $XT", IIC_VecGeneral,
1556 []>, Requires<[In64BitMode]>;
1558 } // IsISA3_0, HasDirectMove
1561 // We want to parse this from asm, but we don't want to emit this as it would
1562 // be emitted with a VSX reg. So leave Emit = 0 here.
1563 def : InstAlias<"mfvrd $rA, $XT",
1564 (MFVRD g8rc:$rA, vrrc:$XT), 0>;
1565 def : InstAlias<"mffprd $rA, $src",
1566 (MFVSRD g8rc:$rA, f8rc:$src)>;
1568 /* Direct moves of various widths from GPR's into VSR's. Each move lines
1569 the value up into element 0 (both BE and LE). Namely, entities smaller than
1570 a doubleword are shifted left and moved for BE. For LE, they're moved, then
1571 swapped to go into the least significant element of the VSR.
1577 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $A, sub_32), 56, 7));
1581 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $A, sub_32), 48, 15));
1585 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $A, sub_32), 32, 31));
1586 dag BE_DWORD_0 = (MTVSRD $A);
1588 dag LE_MTVSRW = (MTVSRD (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $A, sub_32));
1589 dag LE_WORD_1 = (v2i64 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
1590 LE_MTVSRW, sub_64));
1591 dag LE_WORD_0 = (XXPERMDI LE_WORD_1, LE_WORD_1, 2);
1592 dag LE_DWORD_1 = (v2i64 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
1593 BE_DWORD_0, sub_64));
1594 dag LE_DWORD_0 = (XXPERMDI LE_DWORD_1, LE_DWORD_1, 2);
1597 /* Patterns for extracting elements out of vectors. Integer elements are
1598 extracted using direct move operations. Patterns for extracting elements
1599 whose indices are not available at compile time are also provided with
1600 various _VARIABLE_ patterns.
1601 The numbering for the DAG's is for LE, but when used on BE, the correct
1602 LE element can just be used (i.e. LE_BYTE_2 == BE_BYTE_13).
1604 def VectorExtractions {
1605 // Doubleword extraction
1609 (XXPERMDI (COPY_TO_REGCLASS $S, VSRC),
1610 (COPY_TO_REGCLASS $S, VSRC), 2), sub_64));
1611 dag LE_DWORD_1 = (MFVSRD
1613 (v2i64 (COPY_TO_REGCLASS $S, VSRC)), sub_64));
1616 dag LE_WORD_0 = (MFVSRWZ (EXTRACT_SUBREG (XXPERMDI $S, $S, 2), sub_64));
1617 dag LE_WORD_1 = (MFVSRWZ (EXTRACT_SUBREG (XXSLDWI $S, $S, 1), sub_64));
1618 dag LE_WORD_2 = (MFVSRWZ (EXTRACT_SUBREG
1619 (v2i64 (COPY_TO_REGCLASS $S, VSRC)), sub_64));
1620 dag LE_WORD_3 = (MFVSRWZ (EXTRACT_SUBREG (XXSLDWI $S, $S, 3), sub_64));
1622 // Halfword extraction
1623 dag LE_HALF_0 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 0, 48), sub_32));
1624 dag LE_HALF_1 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 48, 48), sub_32));
1625 dag LE_HALF_2 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 32, 48), sub_32));
1626 dag LE_HALF_3 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 16, 48), sub_32));
1627 dag LE_HALF_4 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 0, 48), sub_32));
1628 dag LE_HALF_5 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 48, 48), sub_32));
1629 dag LE_HALF_6 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 32, 48), sub_32));
1630 dag LE_HALF_7 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 16, 48), sub_32));
1633 dag LE_BYTE_0 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 0, 56), sub_32));
1634 dag LE_BYTE_1 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 56, 56), sub_32));
1635 dag LE_BYTE_2 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 48, 56), sub_32));
1636 dag LE_BYTE_3 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 40, 56), sub_32));
1637 dag LE_BYTE_4 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 32, 56), sub_32));
1638 dag LE_BYTE_5 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 24, 56), sub_32));
1639 dag LE_BYTE_6 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 16, 56), sub_32));
1640 dag LE_BYTE_7 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 8, 56), sub_32));
1641 dag LE_BYTE_8 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 0, 56), sub_32));
1642 dag LE_BYTE_9 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 56, 56), sub_32));
1643 dag LE_BYTE_10 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 48, 56), sub_32));
1644 dag LE_BYTE_11 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 40, 56), sub_32));
1645 dag LE_BYTE_12 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 32, 56), sub_32));
1646 dag LE_BYTE_13 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 24, 56), sub_32));
1647 dag LE_BYTE_14 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 16, 56), sub_32));
1648 dag LE_BYTE_15 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 8, 56), sub_32));
1650 /* Variable element number (BE and LE patterns must be specified separately)
1651 This is a rather involved process.
1653 Conceptually, this is how the move is accomplished:
1654 1. Identify which doubleword contains the element
1655 2. Shift in the VMX register so that the correct doubleword is correctly
1656 lined up for the MFVSRD
1657 3. Perform the move so that the element (along with some extra stuff)
1659 4. Right shift within the GPR so that the element is right-justified
1661 Of course, the index is an element number which has a different meaning
1662 on LE/BE so the patterns have to be specified separately.
1664 Note: The final result will be the element right-justified with high
1665 order bits being arbitrarily defined (namely, whatever was in the
1666 vector register to the left of the value originally).
1671 - For elements 0-7, we shift left by 8 bytes since they're on the right
1672 - For elements 8-15, we need not shift (shift left by zero bytes)
1673 This is accomplished by inverting the bits of the index and AND-ing
1674 with 0x8 (i.e. clearing all bits of the index and inverting bit 60).
1676 dag LE_VBYTE_PERM_VEC = (v16i8 (LVSL ZERO8, (ANDC8 (LI8 8), $Idx)));
1679 // - Now that we set up the shift amount, we shift in the VMX register
1680 dag LE_VBYTE_PERMUTE = (v16i8 (VPERM $S, $S, LE_VBYTE_PERM_VEC));
1683 // - The doubleword containing our element is moved to a GPR
1684 dag LE_MV_VBYTE = (MFVSRD
1686 (v2i64 (COPY_TO_REGCLASS LE_VBYTE_PERMUTE, VSRC)),
1690 - Truncate the element number to the range 0-7 (8-15 are symmetrical
1691 and out of range values are truncated accordingly)
1692 - Multiply by 8 as we need to shift right by the number of bits, not bytes
1693 - Shift right in the GPR by the calculated value
1695 dag LE_VBYTE_SHIFT = (EXTRACT_SUBREG (RLDICR (AND8 (LI8 7), $Idx), 3, 60),
1697 dag LE_VARIABLE_BYTE = (EXTRACT_SUBREG (SRD LE_MV_VBYTE, LE_VBYTE_SHIFT),
1700 /* LE variable halfword
1702 - For elements 0-3, we shift left by 8 since they're on the right
1703 - For elements 4-7, we need not shift (shift left by zero bytes)
1704 Similarly to the byte pattern, we invert the bits of the index, but we
1705 AND with 0x4 (i.e. clear all bits of the index and invert bit 61).
1706 Of course, the shift is still by 8 bytes, so we must multiply by 2.
1708 dag LE_VHALF_PERM_VEC =
1709 (v16i8 (LVSL ZERO8, (RLDICR (ANDC8 (LI8 4), $Idx), 1, 62)));
1712 // - Now that we set up the shift amount, we shift in the VMX register
1713 dag LE_VHALF_PERMUTE = (v16i8 (VPERM $S, $S, LE_VHALF_PERM_VEC));
1716 // - The doubleword containing our element is moved to a GPR
1717 dag LE_MV_VHALF = (MFVSRD
1719 (v2i64 (COPY_TO_REGCLASS LE_VHALF_PERMUTE, VSRC)),
1723 - Truncate the element number to the range 0-3 (4-7 are symmetrical
1724 and out of range values are truncated accordingly)
1725 - Multiply by 16 as we need to shift right by the number of bits
1726 - Shift right in the GPR by the calculated value
1728 dag LE_VHALF_SHIFT = (EXTRACT_SUBREG (RLDICR (AND8 (LI8 3), $Idx), 4, 59),
1730 dag LE_VARIABLE_HALF = (EXTRACT_SUBREG (SRD LE_MV_VHALF, LE_VHALF_SHIFT),
1735 - For elements 0-1, we shift left by 8 since they're on the right
1736 - For elements 2-3, we need not shift
1738 dag LE_VWORD_PERM_VEC = (v16i8 (LVSL ZERO8,
1739 (RLDICR (ANDC8 (LI8 2), $Idx), 2, 61)));
1742 // - Now that we set up the shift amount, we shift in the VMX register
1743 dag LE_VWORD_PERMUTE = (v16i8 (VPERM $S, $S, LE_VWORD_PERM_VEC));
1746 // - The doubleword containing our element is moved to a GPR
1747 dag LE_MV_VWORD = (MFVSRD
1749 (v2i64 (COPY_TO_REGCLASS LE_VWORD_PERMUTE, VSRC)),
1753 - Truncate the element number to the range 0-1 (2-3 are symmetrical
1754 and out of range values are truncated accordingly)
1755 - Multiply by 32 as we need to shift right by the number of bits
1756 - Shift right in the GPR by the calculated value
1758 dag LE_VWORD_SHIFT = (EXTRACT_SUBREG (RLDICR (AND8 (LI8 1), $Idx), 5, 58),
1760 dag LE_VARIABLE_WORD = (EXTRACT_SUBREG (SRD LE_MV_VWORD, LE_VWORD_SHIFT),
1763 /* LE variable doubleword
1765 - For element 0, we shift left by 8 since it's on the right
1766 - For element 1, we need not shift
1768 dag LE_VDWORD_PERM_VEC = (v16i8 (LVSL ZERO8,
1769 (RLDICR (ANDC8 (LI8 1), $Idx), 3, 60)));
1772 // - Now that we set up the shift amount, we shift in the VMX register
1773 dag LE_VDWORD_PERMUTE = (v16i8 (VPERM $S, $S, LE_VDWORD_PERM_VEC));
1776 // - The doubleword containing our element is moved to a GPR
1777 // - Number 4. is not needed for the doubleword as the value is 64-bits
1778 dag LE_VARIABLE_DWORD =
1779 (MFVSRD (EXTRACT_SUBREG
1780 (v2i64 (COPY_TO_REGCLASS LE_VDWORD_PERMUTE, VSRC)),
1783 /* LE variable float
1784 - Shift the vector to line up the desired element to BE Word 0
1785 - Convert 32-bit float to a 64-bit single precision float
1787 dag LE_VFLOAT_PERM_VEC = (v16i8 (LVSL ZERO8,
1788 (RLDICR (XOR8 (LI8 3), $Idx), 2, 61)));
1789 dag LE_VFLOAT_PERMUTE = (VPERM $S, $S, LE_VFLOAT_PERM_VEC);
1790 dag LE_VARIABLE_FLOAT = (XSCVSPDPN LE_VFLOAT_PERMUTE);
1792 /* LE variable double
1793 Same as the LE doubleword except there is no move.
1795 dag LE_VDOUBLE_PERMUTE = (v16i8 (VPERM (v16i8 (COPY_TO_REGCLASS $S, VRRC)),
1796 (v16i8 (COPY_TO_REGCLASS $S, VRRC)),
1797 LE_VDWORD_PERM_VEC));
1798 dag LE_VARIABLE_DOUBLE = (COPY_TO_REGCLASS LE_VDOUBLE_PERMUTE, VSRC);
1801 The algorithm here is the same as the LE variable byte except:
1802 - The shift in the VMX register is by 0/8 for opposite element numbers so
1803 we simply AND the element number with 0x8
1804 - The order of elements after the move to GPR is reversed, so we invert
1805 the bits of the index prior to truncating to the range 0-7
1807 dag BE_VBYTE_PERM_VEC = (v16i8 (LVSL ZERO8, (ANDIo8 $Idx, 8)));
1808 dag BE_VBYTE_PERMUTE = (v16i8 (VPERM $S, $S, BE_VBYTE_PERM_VEC));
1809 dag BE_MV_VBYTE = (MFVSRD
1811 (v2i64 (COPY_TO_REGCLASS BE_VBYTE_PERMUTE, VSRC)),
1813 dag BE_VBYTE_SHIFT = (EXTRACT_SUBREG (RLDICR (ANDC8 (LI8 7), $Idx), 3, 60),
1815 dag BE_VARIABLE_BYTE = (EXTRACT_SUBREG (SRD BE_MV_VBYTE, BE_VBYTE_SHIFT),
1818 /* BE variable halfword
1819 The algorithm here is the same as the LE variable halfword except:
1820 - The shift in the VMX register is by 0/8 for opposite element numbers so
1821 we simply AND the element number with 0x4 and multiply by 2
1822 - The order of elements after the move to GPR is reversed, so we invert
1823 the bits of the index prior to truncating to the range 0-3
1825 dag BE_VHALF_PERM_VEC = (v16i8 (LVSL ZERO8,
1826 (RLDICR (ANDIo8 $Idx, 4), 1, 62)));
1827 dag BE_VHALF_PERMUTE = (v16i8 (VPERM $S, $S, BE_VHALF_PERM_VEC));
1828 dag BE_MV_VHALF = (MFVSRD
1830 (v2i64 (COPY_TO_REGCLASS BE_VHALF_PERMUTE, VSRC)),
1832 dag BE_VHALF_SHIFT = (EXTRACT_SUBREG (RLDICR (ANDC8 (LI8 3), $Idx), 4, 59),
1834 dag BE_VARIABLE_HALF = (EXTRACT_SUBREG (SRD BE_MV_VHALF, BE_VHALF_SHIFT),
1838 The algorithm is the same as the LE variable word except:
1839 - The shift in the VMX register happens for opposite element numbers
1840 - The order of elements after the move to GPR is reversed, so we invert
1841 the bits of the index prior to truncating to the range 0-1
1843 dag BE_VWORD_PERM_VEC = (v16i8 (LVSL ZERO8,
1844 (RLDICR (ANDIo8 $Idx, 2), 2, 61)));
1845 dag BE_VWORD_PERMUTE = (v16i8 (VPERM $S, $S, BE_VWORD_PERM_VEC));
1846 dag BE_MV_VWORD = (MFVSRD
1848 (v2i64 (COPY_TO_REGCLASS BE_VWORD_PERMUTE, VSRC)),
1850 dag BE_VWORD_SHIFT = (EXTRACT_SUBREG (RLDICR (ANDC8 (LI8 1), $Idx), 5, 58),
1852 dag BE_VARIABLE_WORD = (EXTRACT_SUBREG (SRD BE_MV_VWORD, BE_VWORD_SHIFT),
1855 /* BE variable doubleword
1856 Same as the LE doubleword except we shift in the VMX register for opposite
1859 dag BE_VDWORD_PERM_VEC = (v16i8 (LVSL ZERO8,
1860 (RLDICR (ANDIo8 $Idx, 1), 3, 60)));
1861 dag BE_VDWORD_PERMUTE = (v16i8 (VPERM $S, $S, BE_VDWORD_PERM_VEC));
1862 dag BE_VARIABLE_DWORD =
1863 (MFVSRD (EXTRACT_SUBREG
1864 (v2i64 (COPY_TO_REGCLASS BE_VDWORD_PERMUTE, VSRC)),
1867 /* BE variable float
1868 - Shift the vector to line up the desired element to BE Word 0
1869 - Convert 32-bit float to a 64-bit single precision float
1871 dag BE_VFLOAT_PERM_VEC = (v16i8 (LVSL ZERO8, (RLDICR $Idx, 2, 61)));
1872 dag BE_VFLOAT_PERMUTE = (VPERM $S, $S, BE_VFLOAT_PERM_VEC);
1873 dag BE_VARIABLE_FLOAT = (XSCVSPDPN BE_VFLOAT_PERMUTE);
1875 /* BE variable double
1876 Same as the BE doubleword except there is no move.
1878 dag BE_VDOUBLE_PERMUTE = (v16i8 (VPERM (v16i8 (COPY_TO_REGCLASS $S, VRRC)),
1879 (v16i8 (COPY_TO_REGCLASS $S, VRRC)),
1880 BE_VDWORD_PERM_VEC));
1881 dag BE_VARIABLE_DOUBLE = (COPY_TO_REGCLASS BE_VDOUBLE_PERMUTE, VSRC);
1884 def NoP9Altivec : Predicate<"!PPCSubTarget->hasP9Altivec()">;
1885 let AddedComplexity = 400 in {
1886 // v4f32 scalar <-> vector conversions (BE)
1887 let Predicates = [IsBigEndian, HasP8Vector] in {
1888 def : Pat<(v4f32 (scalar_to_vector f32:$A)),
1889 (v4f32 (XSCVDPSPN $A))>;
1890 def : Pat<(f32 (vector_extract v4f32:$S, 0)),
1891 (f32 (XSCVSPDPN $S))>;
1892 def : Pat<(f32 (vector_extract v4f32:$S, 1)),
1893 (f32 (XSCVSPDPN (XXSLDWI $S, $S, 1)))>;
1894 def : Pat<(f32 (vector_extract v4f32:$S, 2)),
1895 (f32 (XSCVSPDPN (XXPERMDI $S, $S, 2)))>;
1896 def : Pat<(f32 (vector_extract v4f32:$S, 3)),
1897 (f32 (XSCVSPDPN (XXSLDWI $S, $S, 3)))>;
1898 def : Pat<(f32 (vector_extract v4f32:$S, i64:$Idx)),
1899 (f32 VectorExtractions.BE_VARIABLE_FLOAT)>;
1900 } // IsBigEndian, HasP8Vector
1902 // Variable index vector_extract for v2f64 does not require P8Vector
1903 let Predicates = [IsBigEndian, HasVSX] in
1904 def : Pat<(f64 (vector_extract v2f64:$S, i64:$Idx)),
1905 (f64 VectorExtractions.BE_VARIABLE_DOUBLE)>;
1907 let Predicates = [IsBigEndian, HasDirectMove] in {
1908 // v16i8 scalar <-> vector conversions (BE)
1909 def : Pat<(v16i8 (scalar_to_vector i32:$A)),
1910 (v16i8 (SUBREG_TO_REG (i64 1), MovesToVSR.BE_BYTE_0, sub_64))>;
1911 def : Pat<(v8i16 (scalar_to_vector i32:$A)),
1912 (v8i16 (SUBREG_TO_REG (i64 1), MovesToVSR.BE_HALF_0, sub_64))>;
1913 def : Pat<(v4i32 (scalar_to_vector i32:$A)),
1914 (v4i32 (SUBREG_TO_REG (i64 1), MovesToVSR.BE_WORD_0, sub_64))>;
1915 def : Pat<(v2i64 (scalar_to_vector i64:$A)),
1916 (v2i64 (SUBREG_TO_REG (i64 1), MovesToVSR.BE_DWORD_0, sub_64))>;
1918 // v2i64 scalar <-> vector conversions (BE)
1919 def : Pat<(i64 (vector_extract v2i64:$S, 0)),
1920 (i64 VectorExtractions.LE_DWORD_1)>;
1921 def : Pat<(i64 (vector_extract v2i64:$S, 1)),
1922 (i64 VectorExtractions.LE_DWORD_0)>;
1923 def : Pat<(i64 (vector_extract v2i64:$S, i64:$Idx)),
1924 (i64 VectorExtractions.BE_VARIABLE_DWORD)>;
1925 } // IsBigEndian, HasDirectMove
1927 let Predicates = [IsBigEndian, HasDirectMove, NoP9Altivec] in {
1928 def : Pat<(i32 (vector_extract v16i8:$S, 0)),
1929 (i32 VectorExtractions.LE_BYTE_15)>;
1930 def : Pat<(i32 (vector_extract v16i8:$S, 1)),
1931 (i32 VectorExtractions.LE_BYTE_14)>;
1932 def : Pat<(i32 (vector_extract v16i8:$S, 2)),
1933 (i32 VectorExtractions.LE_BYTE_13)>;
1934 def : Pat<(i32 (vector_extract v16i8:$S, 3)),
1935 (i32 VectorExtractions.LE_BYTE_12)>;
1936 def : Pat<(i32 (vector_extract v16i8:$S, 4)),
1937 (i32 VectorExtractions.LE_BYTE_11)>;
1938 def : Pat<(i32 (vector_extract v16i8:$S, 5)),
1939 (i32 VectorExtractions.LE_BYTE_10)>;
1940 def : Pat<(i32 (vector_extract v16i8:$S, 6)),
1941 (i32 VectorExtractions.LE_BYTE_9)>;
1942 def : Pat<(i32 (vector_extract v16i8:$S, 7)),
1943 (i32 VectorExtractions.LE_BYTE_8)>;
1944 def : Pat<(i32 (vector_extract v16i8:$S, 8)),
1945 (i32 VectorExtractions.LE_BYTE_7)>;
1946 def : Pat<(i32 (vector_extract v16i8:$S, 9)),
1947 (i32 VectorExtractions.LE_BYTE_6)>;
1948 def : Pat<(i32 (vector_extract v16i8:$S, 10)),
1949 (i32 VectorExtractions.LE_BYTE_5)>;
1950 def : Pat<(i32 (vector_extract v16i8:$S, 11)),
1951 (i32 VectorExtractions.LE_BYTE_4)>;
1952 def : Pat<(i32 (vector_extract v16i8:$S, 12)),
1953 (i32 VectorExtractions.LE_BYTE_3)>;
1954 def : Pat<(i32 (vector_extract v16i8:$S, 13)),
1955 (i32 VectorExtractions.LE_BYTE_2)>;
1956 def : Pat<(i32 (vector_extract v16i8:$S, 14)),
1957 (i32 VectorExtractions.LE_BYTE_1)>;
1958 def : Pat<(i32 (vector_extract v16i8:$S, 15)),
1959 (i32 VectorExtractions.LE_BYTE_0)>;
1960 def : Pat<(i32 (vector_extract v16i8:$S, i64:$Idx)),
1961 (i32 VectorExtractions.BE_VARIABLE_BYTE)>;
1963 // v8i16 scalar <-> vector conversions (BE)
1964 def : Pat<(i32 (vector_extract v8i16:$S, 0)),
1965 (i32 VectorExtractions.LE_HALF_7)>;
1966 def : Pat<(i32 (vector_extract v8i16:$S, 1)),
1967 (i32 VectorExtractions.LE_HALF_6)>;
1968 def : Pat<(i32 (vector_extract v8i16:$S, 2)),
1969 (i32 VectorExtractions.LE_HALF_5)>;
1970 def : Pat<(i32 (vector_extract v8i16:$S, 3)),
1971 (i32 VectorExtractions.LE_HALF_4)>;
1972 def : Pat<(i32 (vector_extract v8i16:$S, 4)),
1973 (i32 VectorExtractions.LE_HALF_3)>;
1974 def : Pat<(i32 (vector_extract v8i16:$S, 5)),
1975 (i32 VectorExtractions.LE_HALF_2)>;
1976 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
1977 (i32 VectorExtractions.LE_HALF_1)>;
1978 def : Pat<(i32 (vector_extract v8i16:$S, 7)),
1979 (i32 VectorExtractions.LE_HALF_0)>;
1980 def : Pat<(i32 (vector_extract v8i16:$S, i64:$Idx)),
1981 (i32 VectorExtractions.BE_VARIABLE_HALF)>;
1983 // v4i32 scalar <-> vector conversions (BE)
1984 def : Pat<(i32 (vector_extract v4i32:$S, 0)),
1985 (i32 VectorExtractions.LE_WORD_3)>;
1986 def : Pat<(i32 (vector_extract v4i32:$S, 1)),
1987 (i32 VectorExtractions.LE_WORD_2)>;
1988 def : Pat<(i32 (vector_extract v4i32:$S, 2)),
1989 (i32 VectorExtractions.LE_WORD_1)>;
1990 def : Pat<(i32 (vector_extract v4i32:$S, 3)),
1991 (i32 VectorExtractions.LE_WORD_0)>;
1992 def : Pat<(i32 (vector_extract v4i32:$S, i64:$Idx)),
1993 (i32 VectorExtractions.BE_VARIABLE_WORD)>;
1994 } // IsBigEndian, HasDirectMove, NoP9Altivec
1996 // v4f32 scalar <-> vector conversions (LE)
1997 let Predicates = [IsLittleEndian, HasP8Vector] in {
1998 def : Pat<(v4f32 (scalar_to_vector f32:$A)),
1999 (v4f32 (XXSLDWI (XSCVDPSPN $A), (XSCVDPSPN $A), 1))>;
2000 def : Pat<(f32 (vector_extract v4f32:$S, 0)),
2001 (f32 (XSCVSPDPN (XXSLDWI $S, $S, 3)))>;
2002 def : Pat<(f32 (vector_extract v4f32:$S, 1)),
2003 (f32 (XSCVSPDPN (XXPERMDI $S, $S, 2)))>;
2004 def : Pat<(f32 (vector_extract v4f32:$S, 2)),
2005 (f32 (XSCVSPDPN (XXSLDWI $S, $S, 1)))>;
2006 def : Pat<(f32 (vector_extract v4f32:$S, 3)),
2007 (f32 (XSCVSPDPN $S))>;
2008 def : Pat<(f32 (vector_extract v4f32:$S, i64:$Idx)),
2009 (f32 VectorExtractions.LE_VARIABLE_FLOAT)>;
2010 } // IsLittleEndian, HasP8Vector
2012 // Variable index vector_extract for v2f64 does not require P8Vector
2013 let Predicates = [IsLittleEndian, HasVSX] in
2014 def : Pat<(f64 (vector_extract v2f64:$S, i64:$Idx)),
2015 (f64 VectorExtractions.LE_VARIABLE_DOUBLE)>;
2017 def : Pat<(int_ppc_vsx_stxvd2x_be v2f64:$rS, xoaddr:$dst),
2018 (STXVD2X $rS, xoaddr:$dst)>;
2019 def : Pat<(int_ppc_vsx_stxvw4x_be v4i32:$rS, xoaddr:$dst),
2020 (STXVW4X $rS, xoaddr:$dst)>;
2021 def : Pat<(v4i32 (int_ppc_vsx_lxvw4x_be xoaddr:$src)), (LXVW4X xoaddr:$src)>;
2022 def : Pat<(v2f64 (int_ppc_vsx_lxvd2x_be xoaddr:$src)), (LXVD2X xoaddr:$src)>;
2024 // Variable index unsigned vector_extract on Power9
2025 let Predicates = [HasP9Altivec, IsLittleEndian] in {
2026 def : Pat<(i64 (anyext (i32 (vector_extract v16i8:$S, i64:$Idx)))),
2027 (VEXTUBRX $Idx, $S)>;
2029 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, i64:$Idx)))),
2030 (VEXTUHRX (RLWINM8 $Idx, 1, 28, 30), $S)>;
2031 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 0)))),
2032 (VEXTUHRX (LI8 0), $S)>;
2033 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 1)))),
2034 (VEXTUHRX (LI8 2), $S)>;
2035 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 2)))),
2036 (VEXTUHRX (LI8 4), $S)>;
2037 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 3)))),
2038 (VEXTUHRX (LI8 6), $S)>;
2039 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 4)))),
2040 (VEXTUHRX (LI8 8), $S)>;
2041 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 5)))),
2042 (VEXTUHRX (LI8 10), $S)>;
2043 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 6)))),
2044 (VEXTUHRX (LI8 12), $S)>;
2045 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 7)))),
2046 (VEXTUHRX (LI8 14), $S)>;
2048 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, i64:$Idx)))),
2049 (VEXTUWRX (RLWINM8 $Idx, 2, 28, 29), $S)>;
2050 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 0)))),
2051 (VEXTUWRX (LI8 0), $S)>;
2052 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 1)))),
2053 (VEXTUWRX (LI8 4), $S)>;
2054 // For extracting LE word 2, MFVSRWZ is better than VEXTUWRX
2055 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 2)))),
2056 (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
2057 (i32 VectorExtractions.LE_WORD_2), sub_32)>;
2058 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 3)))),
2059 (VEXTUWRX (LI8 12), $S)>;
2061 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, i64:$Idx)))),
2062 (EXTSW (VEXTUWRX (RLWINM8 $Idx, 2, 28, 29), $S))>;
2063 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 0)))),
2064 (EXTSW (VEXTUWRX (LI8 0), $S))>;
2065 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 1)))),
2066 (EXTSW (VEXTUWRX (LI8 4), $S))>;
2067 // For extracting LE word 2, MFVSRWZ is better than VEXTUWRX
2068 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 2)))),
2069 (EXTSW (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
2070 (i32 VectorExtractions.LE_WORD_2), sub_32))>;
2071 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 3)))),
2072 (EXTSW (VEXTUWRX (LI8 12), $S))>;
2074 def : Pat<(i32 (vector_extract v16i8:$S, i64:$Idx)),
2075 (i32 (EXTRACT_SUBREG (VEXTUBRX $Idx, $S), sub_32))>;
2076 def : Pat<(i32 (vector_extract v16i8:$S, 0)),
2077 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 0), $S), sub_32))>;
2078 def : Pat<(i32 (vector_extract v16i8:$S, 1)),
2079 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 1), $S), sub_32))>;
2080 def : Pat<(i32 (vector_extract v16i8:$S, 2)),
2081 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 2), $S), sub_32))>;
2082 def : Pat<(i32 (vector_extract v16i8:$S, 3)),
2083 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 3), $S), sub_32))>;
2084 def : Pat<(i32 (vector_extract v16i8:$S, 4)),
2085 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 4), $S), sub_32))>;
2086 def : Pat<(i32 (vector_extract v16i8:$S, 5)),
2087 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 5), $S), sub_32))>;
2088 def : Pat<(i32 (vector_extract v16i8:$S, 6)),
2089 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 6), $S), sub_32))>;
2090 def : Pat<(i32 (vector_extract v16i8:$S, 7)),
2091 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 7), $S), sub_32))>;
2092 def : Pat<(i32 (vector_extract v16i8:$S, 8)),
2093 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 8), $S), sub_32))>;
2094 def : Pat<(i32 (vector_extract v16i8:$S, 9)),
2095 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 9), $S), sub_32))>;
2096 def : Pat<(i32 (vector_extract v16i8:$S, 10)),
2097 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 10), $S), sub_32))>;
2098 def : Pat<(i32 (vector_extract v16i8:$S, 11)),
2099 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 11), $S), sub_32))>;
2100 def : Pat<(i32 (vector_extract v16i8:$S, 12)),
2101 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 12), $S), sub_32))>;
2102 def : Pat<(i32 (vector_extract v16i8:$S, 13)),
2103 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 13), $S), sub_32))>;
2104 def : Pat<(i32 (vector_extract v16i8:$S, 14)),
2105 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 14), $S), sub_32))>;
2106 def : Pat<(i32 (vector_extract v16i8:$S, 15)),
2107 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 15), $S), sub_32))>;
2109 def : Pat<(i32 (vector_extract v8i16:$S, i64:$Idx)),
2110 (i32 (EXTRACT_SUBREG (VEXTUHRX
2111 (RLWINM8 $Idx, 1, 28, 30), $S), sub_32))>;
2112 def : Pat<(i32 (vector_extract v8i16:$S, 0)),
2113 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 0), $S), sub_32))>;
2114 def : Pat<(i32 (vector_extract v8i16:$S, 1)),
2115 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 2), $S), sub_32))>;
2116 def : Pat<(i32 (vector_extract v8i16:$S, 2)),
2117 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 4), $S), sub_32))>;
2118 def : Pat<(i32 (vector_extract v8i16:$S, 3)),
2119 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 6), $S), sub_32))>;
2120 def : Pat<(i32 (vector_extract v8i16:$S, 4)),
2121 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 8), $S), sub_32))>;
2122 def : Pat<(i32 (vector_extract v8i16:$S, 5)),
2123 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 10), $S), sub_32))>;
2124 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
2125 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 12), $S), sub_32))>;
2126 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
2127 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 14), $S), sub_32))>;
2129 def : Pat<(i32 (vector_extract v4i32:$S, i64:$Idx)),
2130 (i32 (EXTRACT_SUBREG (VEXTUWRX
2131 (RLWINM8 $Idx, 2, 28, 29), $S), sub_32))>;
2132 def : Pat<(i32 (vector_extract v4i32:$S, 0)),
2133 (i32 (EXTRACT_SUBREG (VEXTUWRX (LI8 0), $S), sub_32))>;
2134 def : Pat<(i32 (vector_extract v4i32:$S, 1)),
2135 (i32 (EXTRACT_SUBREG (VEXTUWRX (LI8 4), $S), sub_32))>;
2136 // For extracting LE word 2, MFVSRWZ is better than VEXTUWRX
2137 def : Pat<(i32 (vector_extract v4i32:$S, 2)),
2138 (i32 VectorExtractions.LE_WORD_2)>;
2139 def : Pat<(i32 (vector_extract v4i32:$S, 3)),
2140 (i32 (EXTRACT_SUBREG (VEXTUWRX (LI8 12), $S), sub_32))>;
2143 let Predicates = [HasP9Altivec, IsBigEndian] in {
2144 def : Pat<(i64 (anyext (i32 (vector_extract v16i8:$S, i64:$Idx)))),
2145 (VEXTUBLX $Idx, $S)>;
2147 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, i64:$Idx)))),
2148 (VEXTUHLX (RLWINM8 $Idx, 1, 28, 30), $S)>;
2149 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 0)))),
2150 (VEXTUHLX (LI8 0), $S)>;
2151 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 1)))),
2152 (VEXTUHLX (LI8 2), $S)>;
2153 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 2)))),
2154 (VEXTUHLX (LI8 4), $S)>;
2155 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 3)))),
2156 (VEXTUHLX (LI8 6), $S)>;
2157 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 4)))),
2158 (VEXTUHLX (LI8 8), $S)>;
2159 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 5)))),
2160 (VEXTUHLX (LI8 10), $S)>;
2161 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 6)))),
2162 (VEXTUHLX (LI8 12), $S)>;
2163 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 7)))),
2164 (VEXTUHLX (LI8 14), $S)>;
2166 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, i64:$Idx)))),
2167 (VEXTUWLX (RLWINM8 $Idx, 2, 28, 29), $S)>;
2168 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 0)))),
2169 (VEXTUWLX (LI8 0), $S)>;
2171 // For extracting BE word 1, MFVSRWZ is better than VEXTUWLX
2172 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 1)))),
2173 (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
2174 (i32 VectorExtractions.LE_WORD_2), sub_32)>;
2175 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 2)))),
2176 (VEXTUWLX (LI8 8), $S)>;
2177 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 3)))),
2178 (VEXTUWLX (LI8 12), $S)>;
2180 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, i64:$Idx)))),
2181 (EXTSW (VEXTUWLX (RLWINM8 $Idx, 2, 28, 29), $S))>;
2182 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 0)))),
2183 (EXTSW (VEXTUWLX (LI8 0), $S))>;
2184 // For extracting BE word 1, MFVSRWZ is better than VEXTUWLX
2185 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 1)))),
2186 (EXTSW (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
2187 (i32 VectorExtractions.LE_WORD_2), sub_32))>;
2188 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 2)))),
2189 (EXTSW (VEXTUWLX (LI8 8), $S))>;
2190 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 3)))),
2191 (EXTSW (VEXTUWLX (LI8 12), $S))>;
2193 def : Pat<(i32 (vector_extract v16i8:$S, i64:$Idx)),
2194 (i32 (EXTRACT_SUBREG (VEXTUBLX $Idx, $S), sub_32))>;
2195 def : Pat<(i32 (vector_extract v16i8:$S, 0)),
2196 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 0), $S), sub_32))>;
2197 def : Pat<(i32 (vector_extract v16i8:$S, 1)),
2198 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 1), $S), sub_32))>;
2199 def : Pat<(i32 (vector_extract v16i8:$S, 2)),
2200 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 2), $S), sub_32))>;
2201 def : Pat<(i32 (vector_extract v16i8:$S, 3)),
2202 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 3), $S), sub_32))>;
2203 def : Pat<(i32 (vector_extract v16i8:$S, 4)),
2204 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 4), $S), sub_32))>;
2205 def : Pat<(i32 (vector_extract v16i8:$S, 5)),
2206 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 5), $S), sub_32))>;
2207 def : Pat<(i32 (vector_extract v16i8:$S, 6)),
2208 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 6), $S), sub_32))>;
2209 def : Pat<(i32 (vector_extract v16i8:$S, 7)),
2210 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 7), $S), sub_32))>;
2211 def : Pat<(i32 (vector_extract v16i8:$S, 8)),
2212 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 8), $S), sub_32))>;
2213 def : Pat<(i32 (vector_extract v16i8:$S, 9)),
2214 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 9), $S), sub_32))>;
2215 def : Pat<(i32 (vector_extract v16i8:$S, 10)),
2216 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 10), $S), sub_32))>;
2217 def : Pat<(i32 (vector_extract v16i8:$S, 11)),
2218 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 11), $S), sub_32))>;
2219 def : Pat<(i32 (vector_extract v16i8:$S, 12)),
2220 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 12), $S), sub_32))>;
2221 def : Pat<(i32 (vector_extract v16i8:$S, 13)),
2222 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 13), $S), sub_32))>;
2223 def : Pat<(i32 (vector_extract v16i8:$S, 14)),
2224 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 14), $S), sub_32))>;
2225 def : Pat<(i32 (vector_extract v16i8:$S, 15)),
2226 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 15), $S), sub_32))>;
2228 def : Pat<(i32 (vector_extract v8i16:$S, i64:$Idx)),
2229 (i32 (EXTRACT_SUBREG (VEXTUHLX
2230 (RLWINM8 $Idx, 1, 28, 30), $S), sub_32))>;
2231 def : Pat<(i32 (vector_extract v8i16:$S, 0)),
2232 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 0), $S), sub_32))>;
2233 def : Pat<(i32 (vector_extract v8i16:$S, 1)),
2234 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 2), $S), sub_32))>;
2235 def : Pat<(i32 (vector_extract v8i16:$S, 2)),
2236 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 4), $S), sub_32))>;
2237 def : Pat<(i32 (vector_extract v8i16:$S, 3)),
2238 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 6), $S), sub_32))>;
2239 def : Pat<(i32 (vector_extract v8i16:$S, 4)),
2240 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 8), $S), sub_32))>;
2241 def : Pat<(i32 (vector_extract v8i16:$S, 5)),
2242 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 10), $S), sub_32))>;
2243 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
2244 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 12), $S), sub_32))>;
2245 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
2246 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 14), $S), sub_32))>;
2248 def : Pat<(i32 (vector_extract v4i32:$S, i64:$Idx)),
2249 (i32 (EXTRACT_SUBREG (VEXTUWLX
2250 (RLWINM8 $Idx, 2, 28, 29), $S), sub_32))>;
2251 def : Pat<(i32 (vector_extract v4i32:$S, 0)),
2252 (i32 (EXTRACT_SUBREG (VEXTUWLX (LI8 0), $S), sub_32))>;
2253 // For extracting BE word 1, MFVSRWZ is better than VEXTUWLX
2254 def : Pat<(i32 (vector_extract v4i32:$S, 1)),
2255 (i32 VectorExtractions.LE_WORD_2)>;
2256 def : Pat<(i32 (vector_extract v4i32:$S, 2)),
2257 (i32 (EXTRACT_SUBREG (VEXTUWLX (LI8 8), $S), sub_32))>;
2258 def : Pat<(i32 (vector_extract v4i32:$S, 3)),
2259 (i32 (EXTRACT_SUBREG (VEXTUWLX (LI8 12), $S), sub_32))>;
2262 let Predicates = [IsLittleEndian, HasDirectMove] in {
2263 // v16i8 scalar <-> vector conversions (LE)
2264 def : Pat<(v16i8 (scalar_to_vector i32:$A)),
2265 (v16i8 (COPY_TO_REGCLASS MovesToVSR.LE_WORD_0, VSRC))>;
2266 def : Pat<(v8i16 (scalar_to_vector i32:$A)),
2267 (v8i16 (COPY_TO_REGCLASS MovesToVSR.LE_WORD_0, VSRC))>;
2268 def : Pat<(v4i32 (scalar_to_vector i32:$A)),
2269 (v4i32 MovesToVSR.LE_WORD_0)>;
2270 def : Pat<(v2i64 (scalar_to_vector i64:$A)),
2271 (v2i64 MovesToVSR.LE_DWORD_0)>;
2272 // v2i64 scalar <-> vector conversions (LE)
2273 def : Pat<(i64 (vector_extract v2i64:$S, 0)),
2274 (i64 VectorExtractions.LE_DWORD_0)>;
2275 def : Pat<(i64 (vector_extract v2i64:$S, 1)),
2276 (i64 VectorExtractions.LE_DWORD_1)>;
2277 def : Pat<(i64 (vector_extract v2i64:$S, i64:$Idx)),
2278 (i64 VectorExtractions.LE_VARIABLE_DWORD)>;
2279 } // IsLittleEndian, HasDirectMove
2281 let Predicates = [IsLittleEndian, HasDirectMove, NoP9Altivec] in {
2282 def : Pat<(i32 (vector_extract v16i8:$S, 0)),
2283 (i32 VectorExtractions.LE_BYTE_0)>;
2284 def : Pat<(i32 (vector_extract v16i8:$S, 1)),
2285 (i32 VectorExtractions.LE_BYTE_1)>;
2286 def : Pat<(i32 (vector_extract v16i8:$S, 2)),
2287 (i32 VectorExtractions.LE_BYTE_2)>;
2288 def : Pat<(i32 (vector_extract v16i8:$S, 3)),
2289 (i32 VectorExtractions.LE_BYTE_3)>;
2290 def : Pat<(i32 (vector_extract v16i8:$S, 4)),
2291 (i32 VectorExtractions.LE_BYTE_4)>;
2292 def : Pat<(i32 (vector_extract v16i8:$S, 5)),
2293 (i32 VectorExtractions.LE_BYTE_5)>;
2294 def : Pat<(i32 (vector_extract v16i8:$S, 6)),
2295 (i32 VectorExtractions.LE_BYTE_6)>;
2296 def : Pat<(i32 (vector_extract v16i8:$S, 7)),
2297 (i32 VectorExtractions.LE_BYTE_7)>;
2298 def : Pat<(i32 (vector_extract v16i8:$S, 8)),
2299 (i32 VectorExtractions.LE_BYTE_8)>;
2300 def : Pat<(i32 (vector_extract v16i8:$S, 9)),
2301 (i32 VectorExtractions.LE_BYTE_9)>;
2302 def : Pat<(i32 (vector_extract v16i8:$S, 10)),
2303 (i32 VectorExtractions.LE_BYTE_10)>;
2304 def : Pat<(i32 (vector_extract v16i8:$S, 11)),
2305 (i32 VectorExtractions.LE_BYTE_11)>;
2306 def : Pat<(i32 (vector_extract v16i8:$S, 12)),
2307 (i32 VectorExtractions.LE_BYTE_12)>;
2308 def : Pat<(i32 (vector_extract v16i8:$S, 13)),
2309 (i32 VectorExtractions.LE_BYTE_13)>;
2310 def : Pat<(i32 (vector_extract v16i8:$S, 14)),
2311 (i32 VectorExtractions.LE_BYTE_14)>;
2312 def : Pat<(i32 (vector_extract v16i8:$S, 15)),
2313 (i32 VectorExtractions.LE_BYTE_15)>;
2314 def : Pat<(i32 (vector_extract v16i8:$S, i64:$Idx)),
2315 (i32 VectorExtractions.LE_VARIABLE_BYTE)>;
2317 // v8i16 scalar <-> vector conversions (LE)
2318 def : Pat<(i32 (vector_extract v8i16:$S, 0)),
2319 (i32 VectorExtractions.LE_HALF_0)>;
2320 def : Pat<(i32 (vector_extract v8i16:$S, 1)),
2321 (i32 VectorExtractions.LE_HALF_1)>;
2322 def : Pat<(i32 (vector_extract v8i16:$S, 2)),
2323 (i32 VectorExtractions.LE_HALF_2)>;
2324 def : Pat<(i32 (vector_extract v8i16:$S, 3)),
2325 (i32 VectorExtractions.LE_HALF_3)>;
2326 def : Pat<(i32 (vector_extract v8i16:$S, 4)),
2327 (i32 VectorExtractions.LE_HALF_4)>;
2328 def : Pat<(i32 (vector_extract v8i16:$S, 5)),
2329 (i32 VectorExtractions.LE_HALF_5)>;
2330 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
2331 (i32 VectorExtractions.LE_HALF_6)>;
2332 def : Pat<(i32 (vector_extract v8i16:$S, 7)),
2333 (i32 VectorExtractions.LE_HALF_7)>;
2334 def : Pat<(i32 (vector_extract v8i16:$S, i64:$Idx)),
2335 (i32 VectorExtractions.LE_VARIABLE_HALF)>;
2337 // v4i32 scalar <-> vector conversions (LE)
2338 def : Pat<(i32 (vector_extract v4i32:$S, 0)),
2339 (i32 VectorExtractions.LE_WORD_0)>;
2340 def : Pat<(i32 (vector_extract v4i32:$S, 1)),
2341 (i32 VectorExtractions.LE_WORD_1)>;
2342 def : Pat<(i32 (vector_extract v4i32:$S, 2)),
2343 (i32 VectorExtractions.LE_WORD_2)>;
2344 def : Pat<(i32 (vector_extract v4i32:$S, 3)),
2345 (i32 VectorExtractions.LE_WORD_3)>;
2346 def : Pat<(i32 (vector_extract v4i32:$S, i64:$Idx)),
2347 (i32 VectorExtractions.LE_VARIABLE_WORD)>;
2348 } // IsLittleEndian, HasDirectMove, NoP9Altivec
2350 let Predicates = [HasDirectMove, HasVSX] in {
2351 // bitconvert f32 -> i32
2352 // (convert to 32-bit fp single, shift right 1 word, move to GPR)
2353 def : Pat<(i32 (bitconvert f32:$S)),
2354 (i32 (MFVSRWZ (EXTRACT_SUBREG
2355 (XXSLDWI (XSCVDPSPN $S), (XSCVDPSPN $S), 3),
2357 // bitconvert i32 -> f32
2358 // (move to FPR, shift left 1 word, convert to 64-bit fp single)
2359 def : Pat<(f32 (bitconvert i32:$A)),
2361 (XXSLDWI MovesToVSR.LE_WORD_1, MovesToVSR.LE_WORD_1, 1)))>;
2363 // bitconvert f64 -> i64
2364 // (move to GPR, nothing else needed)
2365 def : Pat<(i64 (bitconvert f64:$S)),
2368 // bitconvert i64 -> f64
2369 // (move to FPR, nothing else needed)
2370 def : Pat<(f64 (bitconvert i64:$S)),
2374 // Materialize a zero-vector of long long
2375 def : Pat<(v2i64 immAllZerosV),
2380 dag F32_TO_BE_WORD1 = (v4f32 (XXSLDWI (XSCVDPSPN $B), (XSCVDPSPN $B), 3));
2381 dag I32_TO_BE_WORD1 = (COPY_TO_REGCLASS (MTVSRWZ $B), VSRC);
2384 // The following VSX instructions were introduced in Power ISA 3.0
2385 def HasP9Vector : Predicate<"PPCSubTarget->hasP9Vector()">;
2386 let AddedComplexity = 400, Predicates = [HasP9Vector] in {
2388 // [PO VRT XO VRB XO /]
2389 class X_VT5_XO5_VB5<bits<6> opcode, bits<5> xo2, bits<10> xo, string opc,
2391 : X_RD5_XO5_RS5<opcode, xo2, xo, (outs vrrc:$vT), (ins vrrc:$vB),
2392 !strconcat(opc, " $vT, $vB"), IIC_VecFP, pattern>;
2394 // [PO VRT XO VRB XO RO], Round to Odd version of [PO VRT XO VRB XO /]
2395 class X_VT5_XO5_VB5_Ro<bits<6> opcode, bits<5> xo2, bits<10> xo, string opc,
2397 : X_VT5_XO5_VB5<opcode, xo2, xo, opc, pattern>, isDOT;
2399 // [PO VRT XO VRB XO /], but the VRB is only used the left 64 bits (or less),
2400 // So we use different operand class for VRB
2401 class X_VT5_XO5_VB5_TyVB<bits<6> opcode, bits<5> xo2, bits<10> xo, string opc,
2402 RegisterOperand vbtype, list<dag> pattern>
2403 : X_RD5_XO5_RS5<opcode, xo2, xo, (outs vrrc:$vT), (ins vbtype:$vB),
2404 !strconcat(opc, " $vT, $vB"), IIC_VecFP, pattern>;
2406 // [PO VRT XO VRB XO /]
2407 class X_VT5_XO5_VB5_VSFR<bits<6> opcode, bits<5> xo2, bits<10> xo, string opc,
2409 : X_RD5_XO5_RS5<opcode, xo2, xo, (outs vfrc:$vT), (ins vrrc:$vB),
2410 !strconcat(opc, " $vT, $vB"), IIC_VecFP, pattern>;
2412 // [PO VRT XO VRB XO RO], Round to Odd version of [PO VRT XO VRB XO /]
2413 class X_VT5_XO5_VB5_VSFR_Ro<bits<6> opcode, bits<5> xo2, bits<10> xo, string opc,
2415 : X_VT5_XO5_VB5_VSFR<opcode, xo2, xo, opc, pattern>, isDOT;
2417 let UseVSXReg = 1 in {
2418 // [PO T XO B XO BX /]
2419 class XX2_RT5_XO5_XB6<bits<6> opcode, bits<5> xo2, bits<9> xo, string opc,
2421 : XX2_RD5_XO5_RS6<opcode, xo2, xo, (outs g8rc:$rT), (ins vsfrc:$XB),
2422 !strconcat(opc, " $rT, $XB"), IIC_VecFP, pattern>;
2424 // [PO T XO B XO BX TX]
2425 class XX2_XT6_XO5_XB6<bits<6> opcode, bits<5> xo2, bits<9> xo, string opc,
2426 RegisterOperand vtype, list<dag> pattern>
2427 : XX2_RD6_XO5_RS6<opcode, xo2, xo, (outs vtype:$XT), (ins vtype:$XB),
2428 !strconcat(opc, " $XT, $XB"), IIC_VecFP, pattern>;
2430 // [PO T A B XO AX BX TX], src and dest register use different operand class
2431 class XX3_XT5_XA5_XB5<bits<6> opcode, bits<8> xo, string opc,
2432 RegisterOperand xty, RegisterOperand aty, RegisterOperand bty,
2433 InstrItinClass itin, list<dag> pattern>
2434 : XX3Form<opcode, xo, (outs xty:$XT), (ins aty:$XA, bty:$XB),
2435 !strconcat(opc, " $XT, $XA, $XB"), itin, pattern>;
2438 // [PO VRT VRA VRB XO /]
2439 class X_VT5_VA5_VB5<bits<6> opcode, bits<10> xo, string opc,
2441 : XForm_1<opcode, xo, (outs vrrc:$vT), (ins vrrc:$vA, vrrc:$vB),
2442 !strconcat(opc, " $vT, $vA, $vB"), IIC_VecFP, pattern>;
2444 // [PO VRT VRA VRB XO RO], Round to Odd version of [PO VRT VRA VRB XO /]
2445 class X_VT5_VA5_VB5_Ro<bits<6> opcode, bits<10> xo, string opc,
2447 : X_VT5_VA5_VB5<opcode, xo, opc, pattern>, isDOT;
2449 // [PO VRT VRA VRB XO /]
2450 class X_VT5_VA5_VB5_FMA<bits<6> opcode, bits<10> xo, string opc,
2452 : XForm_1<opcode, xo, (outs vrrc:$vT), (ins vrrc:$vTi, vrrc:$vA, vrrc:$vB),
2453 !strconcat(opc, " $vT, $vA, $vB"), IIC_VecFP, pattern>,
2454 RegConstraint<"$vTi = $vT">, NoEncode<"$vTi">;
2456 // [PO VRT VRA VRB XO RO], Round to Odd version of [PO VRT VRA VRB XO /]
2457 class X_VT5_VA5_VB5_FMA_Ro<bits<6> opcode, bits<10> xo, string opc,
2459 : X_VT5_VA5_VB5_FMA<opcode, xo, opc, pattern>, isDOT;
2461 //===--------------------------------------------------------------------===//
2462 // Quad-Precision Scalar Move Instructions:
2465 def XSCPSGNQP : X_VT5_VA5_VB5<63, 100, "xscpsgnqp",
2467 (fcopysign f128:$vB, f128:$vA))]>;
2469 // Absolute/Negative-Absolute/Negate
2470 def XSABSQP : X_VT5_XO5_VB5<63, 0, 804, "xsabsqp",
2471 [(set f128:$vT, (fabs f128:$vB))]>;
2472 def XSNABSQP : X_VT5_XO5_VB5<63, 8, 804, "xsnabsqp",
2473 [(set f128:$vT, (fneg (fabs f128:$vB)))]>;
2474 def XSNEGQP : X_VT5_XO5_VB5<63, 16, 804, "xsnegqp",
2475 [(set f128:$vT, (fneg f128:$vB))]>;
2477 //===--------------------------------------------------------------------===//
2478 // Quad-Precision Scalar Floating-Point Arithmetic Instructions:
2480 // Add/Divide/Multiply/Subtract
2481 let isCommutable = 1 in {
2482 def XSADDQP : X_VT5_VA5_VB5 <63, 4, "xsaddqp",
2483 [(set f128:$vT, (fadd f128:$vA, f128:$vB))]>;
2484 def XSADDQPO : X_VT5_VA5_VB5_Ro<63, 4, "xsaddqpo",
2486 (int_ppc_addf128_round_to_odd
2487 f128:$vA, f128:$vB))]>;
2488 def XSMULQP : X_VT5_VA5_VB5 <63, 36, "xsmulqp",
2489 [(set f128:$vT, (fmul f128:$vA, f128:$vB))]>;
2490 def XSMULQPO : X_VT5_VA5_VB5_Ro<63, 36, "xsmulqpo",
2492 (int_ppc_mulf128_round_to_odd
2493 f128:$vA, f128:$vB))]>;
2496 def XSSUBQP : X_VT5_VA5_VB5 <63, 516, "xssubqp" ,
2497 [(set f128:$vT, (fsub f128:$vA, f128:$vB))]>;
2498 def XSSUBQPO : X_VT5_VA5_VB5_Ro<63, 516, "xssubqpo",
2500 (int_ppc_subf128_round_to_odd
2501 f128:$vA, f128:$vB))]>;
2502 def XSDIVQP : X_VT5_VA5_VB5 <63, 548, "xsdivqp",
2503 [(set f128:$vT, (fdiv f128:$vA, f128:$vB))]>;
2504 def XSDIVQPO : X_VT5_VA5_VB5_Ro<63, 548, "xsdivqpo",
2506 (int_ppc_divf128_round_to_odd
2507 f128:$vA, f128:$vB))]>;
2510 def XSSQRTQP : X_VT5_XO5_VB5 <63, 27, 804, "xssqrtqp",
2511 [(set f128:$vT, (fsqrt f128:$vB))]>;
2512 def XSSQRTQPO : X_VT5_XO5_VB5_Ro<63, 27, 804, "xssqrtqpo",
2514 (int_ppc_sqrtf128_round_to_odd f128:$vB))]>;
2516 // (Negative) Multiply-{Add/Subtract}
2517 def XSMADDQP : X_VT5_VA5_VB5_FMA <63, 388, "xsmaddqp",
2519 (fma f128:$vA, f128:$vB,
2522 def XSMADDQPO : X_VT5_VA5_VB5_FMA_Ro<63, 388, "xsmaddqpo",
2524 (int_ppc_fmaf128_round_to_odd
2525 f128:$vA,f128:$vB,f128:$vTi))]>;
2527 def XSMSUBQP : X_VT5_VA5_VB5_FMA <63, 420, "xsmsubqp" ,
2529 (fma f128:$vA, f128:$vB,
2530 (fneg f128:$vTi)))]>;
2531 def XSMSUBQPO : X_VT5_VA5_VB5_FMA_Ro<63, 420, "xsmsubqpo" ,
2533 (int_ppc_fmaf128_round_to_odd
2534 f128:$vA, f128:$vB, (fneg f128:$vTi)))]>;
2535 def XSNMADDQP : X_VT5_VA5_VB5_FMA <63, 452, "xsnmaddqp",
2537 (fneg (fma f128:$vA, f128:$vB,
2539 def XSNMADDQPO: X_VT5_VA5_VB5_FMA_Ro<63, 452, "xsnmaddqpo",
2541 (fneg (int_ppc_fmaf128_round_to_odd
2542 f128:$vA, f128:$vB, f128:$vTi)))]>;
2543 def XSNMSUBQP : X_VT5_VA5_VB5_FMA <63, 484, "xsnmsubqp",
2545 (fneg (fma f128:$vA, f128:$vB,
2546 (fneg f128:$vTi))))]>;
2547 def XSNMSUBQPO: X_VT5_VA5_VB5_FMA_Ro<63, 484, "xsnmsubqpo",
2549 (fneg (int_ppc_fmaf128_round_to_odd
2550 f128:$vA, f128:$vB, (fneg f128:$vTi))))]>;
2552 // Additional fnmsub patterns: -a*c + b == -(a*c - b)
2553 def : Pat<(fma (fneg f128:$A), f128:$C, f128:$B), (XSNMSUBQP $B, $C, $A)>;
2554 def : Pat<(fma f128:$A, (fneg f128:$C), f128:$B), (XSNMSUBQP $B, $C, $A)>;
2556 //===--------------------------------------------------------------------===//
2557 // Quad/Double-Precision Compare Instructions:
2559 // [PO BF // VRA VRB XO /]
2560 class X_BF3_VA5_VB5<bits<6> opcode, bits<10> xo, string opc,
2562 : XForm_17<opcode, xo, (outs crrc:$crD), (ins vrrc:$VA, vrrc:$VB),
2563 !strconcat(opc, " $crD, $VA, $VB"), IIC_FPCompare> {
2564 let Pattern = pattern;
2567 // QP Compare Ordered/Unordered
2568 def XSCMPOQP : X_BF3_VA5_VB5<63, 132, "xscmpoqp", []>;
2569 def XSCMPUQP : X_BF3_VA5_VB5<63, 644, "xscmpuqp", []>;
2571 // DP/QP Compare Exponents
2572 def XSCMPEXPDP : XX3Form_1<60, 59,
2573 (outs crrc:$crD), (ins vsfrc:$XA, vsfrc:$XB),
2574 "xscmpexpdp $crD, $XA, $XB", IIC_FPCompare, []>,
2576 def XSCMPEXPQP : X_BF3_VA5_VB5<63, 164, "xscmpexpqp", []>;
2578 // DP Compare ==, >=, >, !=
2579 // Use vsrc for XT, because the entire register of XT is set.
2580 // XT.dword[1] = 0x0000_0000_0000_0000
2581 def XSCMPEQDP : XX3_XT5_XA5_XB5<60, 3, "xscmpeqdp", vsrc, vsfrc, vsfrc,
2583 def XSCMPGEDP : XX3_XT5_XA5_XB5<60, 19, "xscmpgedp", vsrc, vsfrc, vsfrc,
2585 def XSCMPGTDP : XX3_XT5_XA5_XB5<60, 11, "xscmpgtdp", vsrc, vsfrc, vsfrc,
2588 //===--------------------------------------------------------------------===//
2589 // Quad-Precision Floating-Point Conversion Instructions:
2592 def XSCVDPQP : X_VT5_XO5_VB5_TyVB<63, 22, 836, "xscvdpqp", vfrc,
2593 [(set f128:$vT, (fpextend f64:$vB))]>;
2595 // Round & Convert QP -> DP (dword[1] is set to zero)
2596 def XSCVQPDP : X_VT5_XO5_VB5_VSFR<63, 20, 836, "xscvqpdp" , []>;
2597 def XSCVQPDPO : X_VT5_XO5_VB5_VSFR_Ro<63, 20, 836, "xscvqpdpo",
2599 (int_ppc_truncf128_round_to_odd
2602 // Truncate & Convert QP -> (Un)Signed (D)Word (dword[1] is set to zero)
2603 def XSCVQPSDZ : X_VT5_XO5_VB5<63, 25, 836, "xscvqpsdz", []>;
2604 def XSCVQPSWZ : X_VT5_XO5_VB5<63, 9, 836, "xscvqpswz", []>;
2605 def XSCVQPUDZ : X_VT5_XO5_VB5<63, 17, 836, "xscvqpudz", []>;
2606 def XSCVQPUWZ : X_VT5_XO5_VB5<63, 1, 836, "xscvqpuwz", []>;
2608 // Convert (Un)Signed DWord -> QP.
2609 def XSCVSDQP : X_VT5_XO5_VB5_TyVB<63, 10, 836, "xscvsdqp", vfrc, []>;
2610 def : Pat<(f128 (sint_to_fp i64:$src)),
2611 (f128 (XSCVSDQP (COPY_TO_REGCLASS $src, VFRC)))>;
2612 def : Pat<(f128 (sint_to_fp (i64 (PPCmfvsr f64:$src)))),
2613 (f128 (XSCVSDQP $src))>;
2614 def : Pat<(f128 (sint_to_fp (i32 (PPCmfvsr f64:$src)))),
2615 (f128 (XSCVSDQP (VEXTSW2Ds $src)))>;
2617 def XSCVUDQP : X_VT5_XO5_VB5_TyVB<63, 2, 836, "xscvudqp", vfrc, []>;
2618 def : Pat<(f128 (uint_to_fp i64:$src)),
2619 (f128 (XSCVUDQP (COPY_TO_REGCLASS $src, VFRC)))>;
2620 def : Pat<(f128 (uint_to_fp (i64 (PPCmfvsr f64:$src)))),
2621 (f128 (XSCVUDQP $src))>;
2623 // Convert (Un)Signed Word -> QP.
2624 def : Pat<(f128 (sint_to_fp i32:$src)),
2625 (f128 (XSCVSDQP (MTVSRWA $src)))>;
2626 def : Pat<(f128 (sint_to_fp (i32 (load xoaddr:$src)))),
2627 (f128 (XSCVSDQP (LIWAX xoaddr:$src)))>;
2628 def : Pat<(f128 (uint_to_fp i32:$src)),
2629 (f128 (XSCVUDQP (MTVSRWZ $src)))>;
2630 def : Pat<(f128 (uint_to_fp (i32 (load xoaddr:$src)))),
2631 (f128 (XSCVUDQP (LIWZX xoaddr:$src)))>;
2633 let UseVSXReg = 1 in {
2634 //===--------------------------------------------------------------------===//
2635 // Round to Floating-Point Integer Instructions
2637 // (Round &) Convert DP <-> HP
2638 // Note! xscvdphp's src and dest register both use the left 64 bits, so we use
2639 // vsfrc for src and dest register. xscvhpdp's src only use the left 16 bits,
2640 // but we still use vsfrc for it.
2641 def XSCVDPHP : XX2_XT6_XO5_XB6<60, 17, 347, "xscvdphp", vsfrc, []>;
2642 def XSCVHPDP : XX2_XT6_XO5_XB6<60, 16, 347, "xscvhpdp", vsfrc, []>;
2645 def XVCVHPSP : XX2_XT6_XO5_XB6<60, 24, 475, "xvcvhpsp", vsrc, []>;
2646 def XVCVSPHP : XX2_XT6_XO5_XB6<60, 25, 475, "xvcvsphp", vsrc,
2648 (int_ppc_vsx_xvcvsphp v4f32:$XB))]>;
2652 // Pattern for matching Vector HP -> Vector SP intrinsic. Defined as a
2653 // separate pattern so that it can convert the input register class from
2654 // VRRC(v8i16) to VSRC.
2655 def : Pat<(v4f32 (int_ppc_vsx_xvcvhpsp v8i16:$A)),
2656 (v4f32 (XVCVHPSP (COPY_TO_REGCLASS $A, VSRC)))>;
2658 class Z23_VT5_R1_VB5_RMC2_EX1<bits<6> opcode, bits<8> xo, bit ex, string opc,
2660 : Z23Form_8<opcode, xo,
2661 (outs vrrc:$vT), (ins u1imm:$r, vrrc:$vB, u2imm:$rmc),
2662 !strconcat(opc, " $r, $vT, $vB, $rmc"), IIC_VecFP, pattern> {
2666 // Round to Quad-Precision Integer [with Inexact]
2667 def XSRQPI : Z23_VT5_R1_VB5_RMC2_EX1<63, 5, 0, "xsrqpi" , []>;
2668 def XSRQPIX : Z23_VT5_R1_VB5_RMC2_EX1<63, 5, 1, "xsrqpix", []>;
2670 // Use current rounding mode
2671 def : Pat<(f128 (fnearbyint f128:$vB)), (f128 (XSRQPI 0, $vB, 3))>;
2672 // Round to nearest, ties away from zero
2673 def : Pat<(f128 (fround f128:$vB)), (f128 (XSRQPI 0, $vB, 0))>;
2674 // Round towards Zero
2675 def : Pat<(f128 (ftrunc f128:$vB)), (f128 (XSRQPI 1, $vB, 1))>;
2676 // Round towards +Inf
2677 def : Pat<(f128 (fceil f128:$vB)), (f128 (XSRQPI 1, $vB, 2))>;
2678 // Round towards -Inf
2679 def : Pat<(f128 (ffloor f128:$vB)), (f128 (XSRQPI 1, $vB, 3))>;
2681 // Use current rounding mode, [with Inexact]
2682 def : Pat<(f128 (frint f128:$vB)), (f128 (XSRQPIX 0, $vB, 3))>;
2684 // Round Quad-Precision to Double-Extended Precision (fp80)
2685 def XSRQPXP : Z23_VT5_R1_VB5_RMC2_EX1<63, 37, 0, "xsrqpxp", []>;
2687 //===--------------------------------------------------------------------===//
2688 // Insert/Extract Instructions
2690 // Insert Exponent DP/QP
2691 // XT NOTE: XT.dword[1] = 0xUUUU_UUUU_UUUU_UUUU
2692 def XSIEXPDP : XX1Form <60, 918, (outs vsrc:$XT), (ins g8rc:$rA, g8rc:$rB),
2693 "xsiexpdp $XT, $rA, $rB", IIC_VecFP, []>, UseVSXReg;
2694 // vB NOTE: only vB.dword[0] is used, that's why we don't use
2695 // X_VT5_VA5_VB5 form
2696 def XSIEXPQP : XForm_18<63, 868, (outs vrrc:$vT), (ins vrrc:$vA, vsfrc:$vB),
2697 "xsiexpqp $vT, $vA, $vB", IIC_VecFP, []>;
2699 def : Pat<(f128 (int_ppc_scalar_insert_exp_qp f128:$vA, i64:$vB)),
2700 (f128 (XSIEXPQP $vA, (MTVSRD $vB)))>;
2702 // Extract Exponent/Significand DP/QP
2703 def XSXEXPDP : XX2_RT5_XO5_XB6<60, 0, 347, "xsxexpdp", []>;
2704 def XSXSIGDP : XX2_RT5_XO5_XB6<60, 1, 347, "xsxsigdp", []>;
2706 def XSXEXPQP : X_VT5_XO5_VB5 <63, 2, 804, "xsxexpqp", []>;
2707 def XSXSIGQP : X_VT5_XO5_VB5 <63, 18, 804, "xsxsigqp", []>;
2709 def : Pat<(i64 (int_ppc_scalar_extract_expq f128:$vA)),
2710 (i64 (MFVSRD (EXTRACT_SUBREG
2711 (v2i64 (XSXEXPQP $vA)), sub_64)))>;
2713 // Vector Insert Word
2714 let UseVSXReg = 1 in {
2715 // XB NOTE: Only XB.dword[1] is used, but we use vsrc on XB.
2717 XX2_RD6_UIM5_RS6<60, 181, (outs vsrc:$XT),
2718 (ins vsrc:$XTi, vsrc:$XB, u4imm:$UIM),
2719 "xxinsertw $XT, $XB, $UIM", IIC_VecFP,
2720 [(set v4i32:$XT, (PPCvecinsert v4i32:$XTi, v4i32:$XB,
2721 imm32SExt16:$UIM))]>,
2722 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">;
2724 // Vector Extract Unsigned Word
2725 def XXEXTRACTUW : XX2_RD6_UIM5_RS6<60, 165,
2726 (outs vsfrc:$XT), (ins vsrc:$XB, u4imm:$UIMM),
2727 "xxextractuw $XT, $XB, $UIMM", IIC_VecFP, []>;
2730 // Vector Insert Exponent DP/SP
2731 def XVIEXPDP : XX3_XT5_XA5_XB5<60, 248, "xviexpdp", vsrc, vsrc, vsrc,
2732 IIC_VecFP, [(set v2f64: $XT,(int_ppc_vsx_xviexpdp v2i64:$XA, v2i64:$XB))]>;
2733 def XVIEXPSP : XX3_XT5_XA5_XB5<60, 216, "xviexpsp", vsrc, vsrc, vsrc,
2734 IIC_VecFP, [(set v4f32: $XT,(int_ppc_vsx_xviexpsp v4i32:$XA, v4i32:$XB))]>;
2736 // Vector Extract Exponent/Significand DP/SP
2737 def XVXEXPDP : XX2_XT6_XO5_XB6<60, 0, 475, "xvxexpdp", vsrc,
2739 (int_ppc_vsx_xvxexpdp v2f64:$XB))]>;
2740 def XVXEXPSP : XX2_XT6_XO5_XB6<60, 8, 475, "xvxexpsp", vsrc,
2742 (int_ppc_vsx_xvxexpsp v4f32:$XB))]>;
2743 def XVXSIGDP : XX2_XT6_XO5_XB6<60, 1, 475, "xvxsigdp", vsrc,
2745 (int_ppc_vsx_xvxsigdp v2f64:$XB))]>;
2746 def XVXSIGSP : XX2_XT6_XO5_XB6<60, 9, 475, "xvxsigsp", vsrc,
2748 (int_ppc_vsx_xvxsigsp v4f32:$XB))]>;
2750 let AddedComplexity = 400, Predicates = [HasP9Vector] in {
2751 // Extra patterns expanding to vector Extract Word/Insert Word
2752 def : Pat<(v4i32 (int_ppc_vsx_xxinsertw v4i32:$A, v2i64:$B, imm:$IMM)),
2753 (v4i32 (XXINSERTW $A, $B, imm:$IMM))>;
2754 def : Pat<(v2i64 (int_ppc_vsx_xxextractuw v2i64:$A, imm:$IMM)),
2755 (v2i64 (COPY_TO_REGCLASS (XXEXTRACTUW $A, imm:$IMM), VSRC))>;
2756 } // AddedComplexity = 400, HasP9Vector
2758 //===--------------------------------------------------------------------===//
2760 // Test Data Class SP/DP/QP
2761 let UseVSXReg = 1 in {
2762 def XSTSTDCSP : XX2_BF3_DCMX7_RS6<60, 298,
2763 (outs crrc:$BF), (ins u7imm:$DCMX, vsfrc:$XB),
2764 "xststdcsp $BF, $XB, $DCMX", IIC_VecFP, []>;
2765 def XSTSTDCDP : XX2_BF3_DCMX7_RS6<60, 362,
2766 (outs crrc:$BF), (ins u7imm:$DCMX, vsfrc:$XB),
2767 "xststdcdp $BF, $XB, $DCMX", IIC_VecFP, []>;
2769 def XSTSTDCQP : X_BF3_DCMX7_RS5 <63, 708,
2770 (outs crrc:$BF), (ins u7imm:$DCMX, vrrc:$vB),
2771 "xststdcqp $BF, $vB, $DCMX", IIC_VecFP, []>;
2773 // Vector Test Data Class SP/DP
2774 let UseVSXReg = 1 in {
2775 def XVTSTDCSP : XX2_RD6_DCMX7_RS6<60, 13, 5,
2776 (outs vsrc:$XT), (ins u7imm:$DCMX, vsrc:$XB),
2777 "xvtstdcsp $XT, $XB, $DCMX", IIC_VecFP,
2779 (int_ppc_vsx_xvtstdcsp v4f32:$XB, imm:$DCMX))]>;
2780 def XVTSTDCDP : XX2_RD6_DCMX7_RS6<60, 15, 5,
2781 (outs vsrc:$XT), (ins u7imm:$DCMX, vsrc:$XB),
2782 "xvtstdcdp $XT, $XB, $DCMX", IIC_VecFP,
2784 (int_ppc_vsx_xvtstdcdp v2f64:$XB, imm:$DCMX))]>;
2787 //===--------------------------------------------------------------------===//
2789 // Maximum/Minimum Type-C/Type-J DP
2790 // XT.dword[1] = 0xUUUU_UUUU_UUUU_UUUU, so we use vsrc for XT
2791 def XSMAXCDP : XX3_XT5_XA5_XB5<60, 128, "xsmaxcdp", vsrc, vsfrc, vsfrc,
2793 def XSMAXJDP : XX3_XT5_XA5_XB5<60, 144, "xsmaxjdp", vsrc, vsfrc, vsfrc,
2795 def XSMINCDP : XX3_XT5_XA5_XB5<60, 136, "xsmincdp", vsrc, vsfrc, vsfrc,
2797 def XSMINJDP : XX3_XT5_XA5_XB5<60, 152, "xsminjdp", vsrc, vsfrc, vsfrc,
2800 //===--------------------------------------------------------------------===//
2802 // Vector Byte-Reverse H/W/D/Q Word
2803 def XXBRH : XX2_XT6_XO5_XB6<60, 7, 475, "xxbrh", vsrc, []>;
2804 def XXBRW : XX2_XT6_XO5_XB6<60, 15, 475, "xxbrw", vsrc, []>;
2805 def XXBRD : XX2_XT6_XO5_XB6<60, 23, 475, "xxbrd", vsrc, []>;
2806 def XXBRQ : XX2_XT6_XO5_XB6<60, 31, 475, "xxbrq", vsrc, []>;
2809 def : Pat<(v8i16 (PPCxxreverse v8i16 :$A)),
2810 (v8i16 (COPY_TO_REGCLASS (XXBRH (COPY_TO_REGCLASS $A, VSRC)), VRRC))>;
2811 def : Pat<(v4i32 (PPCxxreverse v4i32 :$A)),
2812 (v4i32 (XXBRW $A))>;
2813 def : Pat<(v2i64 (PPCxxreverse v2i64 :$A)),
2814 (v2i64 (XXBRD $A))>;
2815 def : Pat<(v1i128 (PPCxxreverse v1i128 :$A)),
2816 (v1i128 (COPY_TO_REGCLASS (XXBRQ (COPY_TO_REGCLASS $A, VSRC)), VRRC))>;
2819 def XXPERM : XX3_XT5_XA5_XB5<60, 26, "xxperm" , vsrc, vsrc, vsrc,
2821 def XXPERMR : XX3_XT5_XA5_XB5<60, 58, "xxpermr", vsrc, vsrc, vsrc,
2824 // Vector Splat Immediate Byte
2825 def XXSPLTIB : X_RD6_IMM8<60, 360, (outs vsrc:$XT), (ins u8imm:$IMM8),
2826 "xxspltib $XT, $IMM8", IIC_VecPerm, []>, UseVSXReg;
2828 //===--------------------------------------------------------------------===//
2829 // Vector/Scalar Load/Store Instructions
2831 // When adding new D-Form loads/stores, be sure to update the ImmToIdxMap in
2832 // PPCRegisterInfo::PPCRegisterInfo and maybe save yourself some debugging.
2833 let mayLoad = 1, mayStore = 0 in {
2835 def LXV : DQ_RD6_RS5_DQ12<61, 1, (outs vsrc:$XT), (ins memrix16:$src),
2836 "lxv $XT, $src", IIC_LdStLFD, []>, UseVSXReg;
2838 def LXSD : DSForm_1<57, 2, (outs vfrc:$vD), (ins memrix:$src),
2839 "lxsd $vD, $src", IIC_LdStLFD, []>;
2840 // Load SP from src, convert it to DP, and place in dword[0]
2841 def LXSSP : DSForm_1<57, 3, (outs vfrc:$vD), (ins memrix:$src),
2842 "lxssp $vD, $src", IIC_LdStLFD, []>;
2844 // [PO T RA RB XO TX] almost equal to [PO S RA RB XO SX], but has different
2845 // "out" and "in" dag
2846 class X_XT6_RA5_RB5<bits<6> opcode, bits<10> xo, string opc,
2847 RegisterOperand vtype, list<dag> pattern>
2848 : XX1Form_memOp<opcode, xo, (outs vtype:$XT), (ins memrr:$src),
2849 !strconcat(opc, " $XT, $src"), IIC_LdStLFD, pattern>, UseVSXReg;
2851 // Load as Integer Byte/Halfword & Zero Indexed
2852 def LXSIBZX : X_XT6_RA5_RB5<31, 781, "lxsibzx", vsfrc,
2853 [(set f64:$XT, (PPClxsizx xoaddr:$src, 1))]>;
2854 def LXSIHZX : X_XT6_RA5_RB5<31, 813, "lxsihzx", vsfrc,
2855 [(set f64:$XT, (PPClxsizx xoaddr:$src, 2))]>;
2857 // Load Vector Halfword*8/Byte*16 Indexed
2858 def LXVH8X : X_XT6_RA5_RB5<31, 812, "lxvh8x" , vsrc, []>;
2859 def LXVB16X : X_XT6_RA5_RB5<31, 876, "lxvb16x", vsrc, []>;
2861 // Load Vector Indexed
2862 def LXVX : X_XT6_RA5_RB5<31, 268, "lxvx" , vsrc,
2863 [(set v2f64:$XT, (load xaddr:$src))]>;
2864 // Load Vector (Left-justified) with Length
2865 def LXVL : XX1Form_memOp<31, 269, (outs vsrc:$XT), (ins memr:$src, g8rc:$rB),
2866 "lxvl $XT, $src, $rB", IIC_LdStLoad,
2867 [(set v4i32:$XT, (int_ppc_vsx_lxvl addr:$src, i64:$rB))]>,
2869 def LXVLL : XX1Form_memOp<31,301, (outs vsrc:$XT), (ins memr:$src, g8rc:$rB),
2870 "lxvll $XT, $src, $rB", IIC_LdStLoad,
2871 [(set v4i32:$XT, (int_ppc_vsx_lxvll addr:$src, i64:$rB))]>,
2874 // Load Vector Word & Splat Indexed
2875 def LXVWSX : X_XT6_RA5_RB5<31, 364, "lxvwsx" , vsrc, []>;
2878 // When adding new D-Form loads/stores, be sure to update the ImmToIdxMap in
2879 // PPCRegisterInfo::PPCRegisterInfo and maybe save yourself some debugging.
2880 let mayStore = 1, mayLoad = 0 in {
2882 def STXV : DQ_RD6_RS5_DQ12<61, 5, (outs), (ins vsrc:$XT, memrix16:$dst),
2883 "stxv $XT, $dst", IIC_LdStSTFD, []>, UseVSXReg;
2885 def STXSD : DSForm_1<61, 2, (outs), (ins vfrc:$vS, memrix:$dst),
2886 "stxsd $vS, $dst", IIC_LdStSTFD, []>;
2887 // Convert DP of dword[0] to SP, and Store to dst
2888 def STXSSP : DSForm_1<61, 3, (outs), (ins vfrc:$vS, memrix:$dst),
2889 "stxssp $vS, $dst", IIC_LdStSTFD, []>;
2891 // [PO S RA RB XO SX]
2892 class X_XS6_RA5_RB5<bits<6> opcode, bits<10> xo, string opc,
2893 RegisterOperand vtype, list<dag> pattern>
2894 : XX1Form_memOp<opcode, xo, (outs), (ins vtype:$XT, memrr:$dst),
2895 !strconcat(opc, " $XT, $dst"), IIC_LdStSTFD, pattern>, UseVSXReg;
2897 // Store as Integer Byte/Halfword Indexed
2898 def STXSIBX : X_XS6_RA5_RB5<31, 909, "stxsibx" , vsfrc,
2899 [(PPCstxsix f64:$XT, xoaddr:$dst, 1)]>;
2900 def STXSIHX : X_XS6_RA5_RB5<31, 941, "stxsihx" , vsfrc,
2901 [(PPCstxsix f64:$XT, xoaddr:$dst, 2)]>;
2902 let isCodeGenOnly = 1 in {
2903 def STXSIBXv : X_XS6_RA5_RB5<31, 909, "stxsibx" , vrrc, []>;
2904 def STXSIHXv : X_XS6_RA5_RB5<31, 941, "stxsihx" , vrrc, []>;
2907 // Store Vector Halfword*8/Byte*16 Indexed
2908 def STXVH8X : X_XS6_RA5_RB5<31, 940, "stxvh8x" , vsrc, []>;
2909 def STXVB16X : X_XS6_RA5_RB5<31, 1004, "stxvb16x", vsrc, []>;
2911 // Store Vector Indexed
2912 def STXVX : X_XS6_RA5_RB5<31, 396, "stxvx" , vsrc,
2913 [(store v2f64:$XT, xaddr:$dst)]>;
2915 // Store Vector (Left-justified) with Length
2916 def STXVL : XX1Form_memOp<31, 397, (outs),
2917 (ins vsrc:$XT, memr:$dst, g8rc:$rB),
2918 "stxvl $XT, $dst, $rB", IIC_LdStLoad,
2919 [(int_ppc_vsx_stxvl v4i32:$XT, addr:$dst,
2922 def STXVLL : XX1Form_memOp<31, 429, (outs),
2923 (ins vsrc:$XT, memr:$dst, g8rc:$rB),
2924 "stxvll $XT, $dst, $rB", IIC_LdStLoad,
2925 [(int_ppc_vsx_stxvll v4i32:$XT, addr:$dst,
2930 let Predicates = [IsLittleEndian] in {
2931 def: Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 0)))))),
2932 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 3))))>;
2933 def: Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 1)))))),
2934 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 2))))>;
2935 def: Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 2)))))),
2936 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 1))))>;
2937 def: Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 3)))))),
2938 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 0))))>;
2939 def: Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 0)))))),
2940 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 3)), VSFRC))>;
2941 def: Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 1)))))),
2942 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 2)), VSFRC))>;
2943 def: Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 2)))))),
2944 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 1)), VSFRC))>;
2945 def: Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 3)))))),
2946 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 0)), VSFRC))>;
2949 let Predicates = [IsBigEndian] in {
2950 def: Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 0)))))),
2951 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 0))))>;
2952 def: Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 1)))))),
2953 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 1))))>;
2954 def: Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 2)))))),
2955 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 2))))>;
2956 def: Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 3)))))),
2957 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 3))))>;
2958 def: Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 0)))))),
2959 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 0)), VSFRC))>;
2960 def: Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 1)))))),
2961 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 1)), VSFRC))>;
2962 def: Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 2)))))),
2963 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 2)), VSFRC))>;
2964 def: Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 3)))))),
2965 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 3)), VSFRC))>;
2968 // Alternate patterns for PPCmtvsrz where the output is v8i16 or v16i8 instead
2970 def : Pat<(v8i16 (PPCmtvsrz i32:$A)),
2971 (v8i16 (SUBREG_TO_REG (i64 1), (MTVSRWZ $A), sub_64))>;
2972 def : Pat<(v16i8 (PPCmtvsrz i32:$A)),
2973 (v16i8 (SUBREG_TO_REG (i64 1), (MTVSRWZ $A), sub_64))>;
2975 // Patterns for which instructions from ISA 3.0 are a better match
2976 let Predicates = [IsLittleEndian, HasP9Vector] in {
2977 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 0)))))),
2978 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 12)))>;
2979 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 1)))))),
2980 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 8)))>;
2981 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 2)))))),
2982 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 4)))>;
2983 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 3)))))),
2984 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 0)))>;
2985 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 0)))))),
2986 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 12)))>;
2987 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 1)))))),
2988 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 8)))>;
2989 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 2)))))),
2990 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 4)))>;
2991 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 3)))))),
2992 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 0)))>;
2993 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 0)),
2994 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 12))>;
2995 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 1)),
2996 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 8))>;
2997 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 2)),
2998 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 4))>;
2999 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 3)),
3000 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 0))>;
3001 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 0)),
3002 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 12))>;
3003 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 1)),
3004 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 8))>;
3005 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 2)),
3006 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 4))>;
3007 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 3)),
3008 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 0))>;
3009 } // IsLittleEndian, HasP9Vector
3011 let Predicates = [IsBigEndian, HasP9Vector] in {
3012 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 0)))))),
3013 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 0)))>;
3014 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 1)))))),
3015 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 4)))>;
3016 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 2)))))),
3017 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 8)))>;
3018 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 3)))))),
3019 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 12)))>;
3020 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 0)))))),
3021 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 0)))>;
3022 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 1)))))),
3023 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 4)))>;
3024 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 2)))))),
3025 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 8)))>;
3026 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 3)))))),
3027 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 12)))>;
3028 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 0)),
3029 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 0))>;
3030 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 1)),
3031 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 4))>;
3032 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 2)),
3033 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 8))>;
3034 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 3)),
3035 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 12))>;
3036 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 0)),
3037 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 0))>;
3038 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 1)),
3039 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 4))>;
3040 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 2)),
3041 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 8))>;
3042 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 3)),
3043 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 12))>;
3044 } // IsLittleEndian, HasP9Vector
3046 // D-Form Load/Store
3047 def : Pat<(v4i32 (quadwOffsetLoad iqaddr:$src)), (LXV memrix16:$src)>;
3048 def : Pat<(v4f32 (quadwOffsetLoad iqaddr:$src)), (LXV memrix16:$src)>;
3049 def : Pat<(v2i64 (quadwOffsetLoad iqaddr:$src)), (LXV memrix16:$src)>;
3050 def : Pat<(v2f64 (quadwOffsetLoad iqaddr:$src)), (LXV memrix16:$src)>;
3051 def : Pat<(f128 (quadwOffsetLoad iqaddr:$src)),
3052 (COPY_TO_REGCLASS (LXV memrix16:$src), VRRC)>;
3053 def : Pat<(v4i32 (int_ppc_vsx_lxvw4x iqaddr:$src)), (LXV memrix16:$src)>;
3054 def : Pat<(v2f64 (int_ppc_vsx_lxvd2x iqaddr:$src)), (LXV memrix16:$src)>;
3056 def : Pat<(quadwOffsetStore v4f32:$rS, iqaddr:$dst), (STXV $rS, memrix16:$dst)>;
3057 def : Pat<(quadwOffsetStore v4i32:$rS, iqaddr:$dst), (STXV $rS, memrix16:$dst)>;
3058 def : Pat<(quadwOffsetStore v2f64:$rS, iqaddr:$dst), (STXV $rS, memrix16:$dst)>;
3059 def : Pat<(quadwOffsetStore f128:$rS, iqaddr:$dst),
3060 (STXV (COPY_TO_REGCLASS $rS, VSRC), memrix16:$dst)>;
3061 def : Pat<(quadwOffsetStore v2i64:$rS, iqaddr:$dst), (STXV $rS, memrix16:$dst)>;
3062 def : Pat<(int_ppc_vsx_stxvw4x v4i32:$rS, iqaddr:$dst),
3063 (STXV $rS, memrix16:$dst)>;
3064 def : Pat<(int_ppc_vsx_stxvd2x v2f64:$rS, iqaddr:$dst),
3065 (STXV $rS, memrix16:$dst)>;
3068 def : Pat<(v2f64 (nonQuadwOffsetLoad xoaddr:$src)), (LXVX xoaddr:$src)>;
3069 def : Pat<(v2i64 (nonQuadwOffsetLoad xoaddr:$src)), (LXVX xoaddr:$src)>;
3070 def : Pat<(v4f32 (nonQuadwOffsetLoad xoaddr:$src)), (LXVX xoaddr:$src)>;
3071 def : Pat<(v4i32 (nonQuadwOffsetLoad xoaddr:$src)), (LXVX xoaddr:$src)>;
3072 def : Pat<(v4i32 (int_ppc_vsx_lxvw4x xoaddr:$src)), (LXVX xoaddr:$src)>;
3073 def : Pat<(v2f64 (int_ppc_vsx_lxvd2x xoaddr:$src)), (LXVX xoaddr:$src)>;
3074 def : Pat<(f128 (nonQuadwOffsetLoad xoaddr:$src)),
3075 (COPY_TO_REGCLASS (LXVX xoaddr:$src), VRRC)>;
3076 def : Pat<(nonQuadwOffsetStore f128:$rS, xoaddr:$dst),
3077 (STXVX (COPY_TO_REGCLASS $rS, VSRC), xoaddr:$dst)>;
3078 def : Pat<(nonQuadwOffsetStore v2f64:$rS, xoaddr:$dst),
3079 (STXVX $rS, xoaddr:$dst)>;
3080 def : Pat<(nonQuadwOffsetStore v2i64:$rS, xoaddr:$dst),
3081 (STXVX $rS, xoaddr:$dst)>;
3082 def : Pat<(nonQuadwOffsetStore v4f32:$rS, xoaddr:$dst),
3083 (STXVX $rS, xoaddr:$dst)>;
3084 def : Pat<(nonQuadwOffsetStore v4i32:$rS, xoaddr:$dst),
3085 (STXVX $rS, xoaddr:$dst)>;
3086 def : Pat<(int_ppc_vsx_stxvw4x v4i32:$rS, xoaddr:$dst),
3087 (STXVX $rS, xoaddr:$dst)>;
3088 def : Pat<(int_ppc_vsx_stxvd2x v2f64:$rS, xoaddr:$dst),
3089 (STXVX $rS, xoaddr:$dst)>;
3091 let AddedComplexity = 400 in {
3092 // LIWAX - This instruction is used for sign extending i32 -> i64.
3093 // LIWZX - This instruction will be emitted for i32, f32, and when
3094 // zero-extending i32 to i64 (zext i32 -> i64).
3095 let Predicates = [IsLittleEndian] in {
3097 def : Pat<(v2i64 (scalar_to_vector (i64 (sextloadi32 xoaddr:$src)))),
3099 (COPY_TO_REGCLASS (LIWAX xoaddr:$src), VSRC), 2))>;
3101 def : Pat<(v2i64 (scalar_to_vector (i64 (zextloadi32 xoaddr:$src)))),
3103 (COPY_TO_REGCLASS (LIWZX xoaddr:$src), VSRC), 2))>;
3105 def : Pat<(v4i32 (scalar_to_vector (i32 (load xoaddr:$src)))),
3107 (COPY_TO_REGCLASS (LIWZX xoaddr:$src), VSRC), 2))>;
3109 def : Pat<(v4f32 (scalar_to_vector (f32 (load xoaddr:$src)))),
3111 (COPY_TO_REGCLASS (LIWZX xoaddr:$src), VSRC), 2))>;
3114 let Predicates = [IsBigEndian] in {
3115 def : Pat<(v2i64 (scalar_to_vector (i64 (sextloadi32 xoaddr:$src)))),
3116 (v2i64 (COPY_TO_REGCLASS (LIWAX xoaddr:$src), VSRC))>;
3118 def : Pat<(v2i64 (scalar_to_vector (i64 (zextloadi32 xoaddr:$src)))),
3119 (v2i64 (COPY_TO_REGCLASS (LIWZX xoaddr:$src), VSRC))>;
3121 def : Pat<(v4i32 (scalar_to_vector (i32 (load xoaddr:$src)))),
3123 (COPY_TO_REGCLASS (LIWZX xoaddr:$src), VSRC), 1))>;
3125 def : Pat<(v4f32 (scalar_to_vector (f32 (load xoaddr:$src)))),
3127 (COPY_TO_REGCLASS (LIWZX xoaddr:$src), VSRC), 1))>;
3132 // Build vectors from i8 loads
3133 def : Pat<(v16i8 (scalar_to_vector ScalarLoads.Li8)),
3134 (v16i8 (VSPLTBs 7, (LXSIBZX xoaddr:$src)))>;
3135 def : Pat<(v8i16 (scalar_to_vector ScalarLoads.ZELi8)),
3136 (v8i16 (VSPLTHs 3, (LXSIBZX xoaddr:$src)))>;
3137 def : Pat<(v4i32 (scalar_to_vector ScalarLoads.ZELi8)),
3138 (v4i32 (XXSPLTWs (LXSIBZX xoaddr:$src), 1))>;
3139 def : Pat<(v2i64 (scalar_to_vector ScalarLoads.ZELi8i64)),
3140 (v2i64 (XXPERMDIs (LXSIBZX xoaddr:$src), 0))>;
3141 def : Pat<(v4i32 (scalar_to_vector ScalarLoads.SELi8)),
3142 (v4i32 (XXSPLTWs (VEXTSB2Ws (LXSIBZX xoaddr:$src)), 1))>;
3143 def : Pat<(v2i64 (scalar_to_vector ScalarLoads.SELi8i64)),
3144 (v2i64 (XXPERMDIs (VEXTSB2Ds (LXSIBZX xoaddr:$src)), 0))>;
3146 // Build vectors from i16 loads
3147 def : Pat<(v8i16 (scalar_to_vector ScalarLoads.Li16)),
3148 (v8i16 (VSPLTHs 3, (LXSIHZX xoaddr:$src)))>;
3149 def : Pat<(v4i32 (scalar_to_vector ScalarLoads.ZELi16)),
3150 (v4i32 (XXSPLTWs (LXSIHZX xoaddr:$src), 1))>;
3151 def : Pat<(v2i64 (scalar_to_vector ScalarLoads.ZELi16i64)),
3152 (v2i64 (XXPERMDIs (LXSIHZX xoaddr:$src), 0))>;
3153 def : Pat<(v4i32 (scalar_to_vector ScalarLoads.SELi16)),
3154 (v4i32 (XXSPLTWs (VEXTSH2Ws (LXSIHZX xoaddr:$src)), 1))>;
3155 def : Pat<(v2i64 (scalar_to_vector ScalarLoads.SELi16i64)),
3156 (v2i64 (XXPERMDIs (VEXTSH2Ds (LXSIHZX xoaddr:$src)), 0))>;
3158 let Predicates = [IsBigEndian, HasP9Vector] in {
3159 // Scalar stores of i8
3160 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 0)), xoaddr:$dst),
3161 (STXSIBXv (v16i8 (VSLDOI $S, $S, 9)), xoaddr:$dst)>;
3162 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 1)), xoaddr:$dst),
3163 (STXSIBXv (v16i8 (VSLDOI $S, $S, 10)), xoaddr:$dst)>;
3164 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 2)), xoaddr:$dst),
3165 (STXSIBXv (v16i8 (VSLDOI $S, $S, 11)), xoaddr:$dst)>;
3166 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 3)), xoaddr:$dst),
3167 (STXSIBXv (v16i8 (VSLDOI $S, $S, 12)), xoaddr:$dst)>;
3168 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 4)), xoaddr:$dst),
3169 (STXSIBXv (v16i8 (VSLDOI $S, $S, 13)), xoaddr:$dst)>;
3170 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 5)), xoaddr:$dst),
3171 (STXSIBXv (v16i8 (VSLDOI $S, $S, 14)), xoaddr:$dst)>;
3172 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 6)), xoaddr:$dst),
3173 (STXSIBXv (v16i8 (VSLDOI $S, $S, 15)), xoaddr:$dst)>;
3174 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 7)), xoaddr:$dst),
3175 (STXSIBXv $S, xoaddr:$dst)>;
3176 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 8)), xoaddr:$dst),
3177 (STXSIBXv (v16i8 (VSLDOI $S, $S, 1)), xoaddr:$dst)>;
3178 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 9)), xoaddr:$dst),
3179 (STXSIBXv (v16i8 (VSLDOI $S, $S, 2)), xoaddr:$dst)>;
3180 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 10)), xoaddr:$dst),
3181 (STXSIBXv (v16i8 (VSLDOI $S, $S, 3)), xoaddr:$dst)>;
3182 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 11)), xoaddr:$dst),
3183 (STXSIBXv (v16i8 (VSLDOI $S, $S, 4)), xoaddr:$dst)>;
3184 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 12)), xoaddr:$dst),
3185 (STXSIBXv (v16i8 (VSLDOI $S, $S, 5)), xoaddr:$dst)>;
3186 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 13)), xoaddr:$dst),
3187 (STXSIBXv (v16i8 (VSLDOI $S, $S, 6)), xoaddr:$dst)>;
3188 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 14)), xoaddr:$dst),
3189 (STXSIBXv (v16i8 (VSLDOI $S, $S, 7)), xoaddr:$dst)>;
3190 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 15)), xoaddr:$dst),
3191 (STXSIBXv (v16i8 (VSLDOI $S, $S, 8)), xoaddr:$dst)>;
3193 // Scalar stores of i16
3194 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 0)), xoaddr:$dst),
3195 (STXSIHXv (v16i8 (VSLDOI $S, $S, 10)), xoaddr:$dst)>;
3196 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 1)), xoaddr:$dst),
3197 (STXSIHXv (v16i8 (VSLDOI $S, $S, 12)), xoaddr:$dst)>;
3198 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 2)), xoaddr:$dst),
3199 (STXSIHXv (v16i8 (VSLDOI $S, $S, 14)), xoaddr:$dst)>;
3200 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 3)), xoaddr:$dst),
3201 (STXSIHXv $S, xoaddr:$dst)>;
3202 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 4)), xoaddr:$dst),
3203 (STXSIHXv (v16i8 (VSLDOI $S, $S, 2)), xoaddr:$dst)>;
3204 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 5)), xoaddr:$dst),
3205 (STXSIHXv (v16i8 (VSLDOI $S, $S, 4)), xoaddr:$dst)>;
3206 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 6)), xoaddr:$dst),
3207 (STXSIHXv (v16i8 (VSLDOI $S, $S, 6)), xoaddr:$dst)>;
3208 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 7)), xoaddr:$dst),
3209 (STXSIHXv (v16i8 (VSLDOI $S, $S, 8)), xoaddr:$dst)>;
3210 } // IsBigEndian, HasP9Vector
3212 let Predicates = [IsLittleEndian, HasP9Vector] in {
3213 // Scalar stores of i8
3214 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 0)), xoaddr:$dst),
3215 (STXSIBXv (v16i8 (VSLDOI $S, $S, 8)), xoaddr:$dst)>;
3216 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 1)), xoaddr:$dst),
3217 (STXSIBXv (v16i8 (VSLDOI $S, $S, 7)), xoaddr:$dst)>;
3218 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 2)), xoaddr:$dst),
3219 (STXSIBXv (v16i8 (VSLDOI $S, $S, 6)), xoaddr:$dst)>;
3220 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 3)), xoaddr:$dst),
3221 (STXSIBXv (v16i8 (VSLDOI $S, $S, 5)), xoaddr:$dst)>;
3222 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 4)), xoaddr:$dst),
3223 (STXSIBXv (v16i8 (VSLDOI $S, $S, 4)), xoaddr:$dst)>;
3224 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 5)), xoaddr:$dst),
3225 (STXSIBXv (v16i8 (VSLDOI $S, $S, 3)), xoaddr:$dst)>;
3226 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 6)), xoaddr:$dst),
3227 (STXSIBXv (v16i8 (VSLDOI $S, $S, 2)), xoaddr:$dst)>;
3228 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 7)), xoaddr:$dst),
3229 (STXSIBXv (v16i8 (VSLDOI $S, $S, 1)), xoaddr:$dst)>;
3230 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 8)), xoaddr:$dst),
3231 (STXSIBXv $S, xoaddr:$dst)>;
3232 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 9)), xoaddr:$dst),
3233 (STXSIBXv (v16i8 (VSLDOI $S, $S, 15)), xoaddr:$dst)>;
3234 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 10)), xoaddr:$dst),
3235 (STXSIBXv (v16i8 (VSLDOI $S, $S, 14)), xoaddr:$dst)>;
3236 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 11)), xoaddr:$dst),
3237 (STXSIBXv (v16i8 (VSLDOI $S, $S, 13)), xoaddr:$dst)>;
3238 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 12)), xoaddr:$dst),
3239 (STXSIBXv (v16i8 (VSLDOI $S, $S, 12)), xoaddr:$dst)>;
3240 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 13)), xoaddr:$dst),
3241 (STXSIBXv (v16i8 (VSLDOI $S, $S, 11)), xoaddr:$dst)>;
3242 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 14)), xoaddr:$dst),
3243 (STXSIBXv (v16i8 (VSLDOI $S, $S, 10)), xoaddr:$dst)>;
3244 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 15)), xoaddr:$dst),
3245 (STXSIBXv (v16i8 (VSLDOI $S, $S, 9)), xoaddr:$dst)>;
3247 // Scalar stores of i16
3248 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 0)), xoaddr:$dst),
3249 (STXSIHXv (v16i8 (VSLDOI $S, $S, 8)), xoaddr:$dst)>;
3250 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 1)), xoaddr:$dst),
3251 (STXSIHXv (v16i8 (VSLDOI $S, $S, 6)), xoaddr:$dst)>;
3252 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 2)), xoaddr:$dst),
3253 (STXSIHXv (v16i8 (VSLDOI $S, $S, 4)), xoaddr:$dst)>;
3254 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 3)), xoaddr:$dst),
3255 (STXSIHXv (v16i8 (VSLDOI $S, $S, 2)), xoaddr:$dst)>;
3256 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 4)), xoaddr:$dst),
3257 (STXSIHXv $S, xoaddr:$dst)>;
3258 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 5)), xoaddr:$dst),
3259 (STXSIHXv (v16i8 (VSLDOI $S, $S, 14)), xoaddr:$dst)>;
3260 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 6)), xoaddr:$dst),
3261 (STXSIHXv (v16i8 (VSLDOI $S, $S, 12)), xoaddr:$dst)>;
3262 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 7)), xoaddr:$dst),
3263 (STXSIHXv (v16i8 (VSLDOI $S, $S, 10)), xoaddr:$dst)>;
3264 } // IsLittleEndian, HasP9Vector
3267 // Vector sign extensions
3268 def : Pat<(f64 (PPCVexts f64:$A, 1)),
3269 (f64 (COPY_TO_REGCLASS (VEXTSB2Ds $A), VSFRC))>;
3270 def : Pat<(f64 (PPCVexts f64:$A, 2)),
3271 (f64 (COPY_TO_REGCLASS (VEXTSH2Ds $A), VSFRC))>;
3273 def DFLOADf32 : PPCPostRAExpPseudo<(outs vssrc:$XT), (ins memrix:$src),
3275 [(set f32:$XT, (load ixaddr:$src))]>;
3276 def DFLOADf64 : PPCPostRAExpPseudo<(outs vsfrc:$XT), (ins memrix:$src),
3278 [(set f64:$XT, (load ixaddr:$src))]>;
3279 def DFSTOREf32 : PPCPostRAExpPseudo<(outs), (ins vssrc:$XT, memrix:$dst),
3281 [(store f32:$XT, ixaddr:$dst)]>;
3282 def DFSTOREf64 : PPCPostRAExpPseudo<(outs), (ins vsfrc:$XT, memrix:$dst),
3284 [(store f64:$XT, ixaddr:$dst)]>;
3286 def : Pat<(f64 (extloadf32 ixaddr:$src)),
3287 (COPY_TO_REGCLASS (DFLOADf32 ixaddr:$src), VSFRC)>;
3288 def : Pat<(f32 (fpround (f64 (extloadf32 ixaddr:$src)))),
3289 (f32 (DFLOADf32 ixaddr:$src))>;
3292 let AddedComplexity = 400 in {
3293 // The following pseudoinstructions are used to ensure the utilization
3294 // of all 64 VSX registers.
3295 let Predicates = [IsLittleEndian, HasP9Vector] in {
3296 def : Pat<(v2i64 (scalar_to_vector (i64 (load ixaddr:$src)))),
3298 (COPY_TO_REGCLASS (DFLOADf64 ixaddr:$src), VSRC), 2))>;
3299 def : Pat<(v2i64 (scalar_to_vector (i64 (load xaddr:$src)))),
3301 (COPY_TO_REGCLASS (XFLOADf64 xaddr:$src), VSRC), 2))>;
3303 def : Pat<(v2f64 (scalar_to_vector (f64 (load ixaddr:$src)))),
3305 (COPY_TO_REGCLASS (DFLOADf64 ixaddr:$src), VSRC), 2))>;
3306 def : Pat<(v2f64 (scalar_to_vector (f64 (load xaddr:$src)))),
3308 (COPY_TO_REGCLASS (XFLOADf64 xaddr:$src), VSRC), 2))>;
3309 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), xaddr:$src),
3310 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
3311 sub_64), xaddr:$src)>;
3312 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), xaddr:$src),
3313 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
3314 sub_64), xaddr:$src)>;
3315 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), xaddr:$src),
3316 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), xaddr:$src)>;
3317 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), xaddr:$src),
3318 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), xaddr:$src)>;
3319 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), ixaddr:$src),
3320 (DFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
3321 sub_64), ixaddr:$src)>;
3322 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), ixaddr:$src),
3323 (DFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2), sub_64),
3325 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), ixaddr:$src),
3326 (DFSTOREf64 (EXTRACT_SUBREG $A, sub_64), ixaddr:$src)>;
3327 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), ixaddr:$src),
3328 (DFSTOREf64 (EXTRACT_SUBREG $A, sub_64), ixaddr:$src)>;
3329 } // IsLittleEndian, HasP9Vector
3331 let Predicates = [IsBigEndian, HasP9Vector] in {
3332 def : Pat<(v2i64 (scalar_to_vector (i64 (load ixaddr:$src)))),
3333 (v2i64 (COPY_TO_REGCLASS (DFLOADf64 ixaddr:$src), VSRC))>;
3334 def : Pat<(v2i64 (scalar_to_vector (i64 (load xaddr:$src)))),
3335 (v2i64 (COPY_TO_REGCLASS (XFLOADf64 xaddr:$src), VSRC))>;
3337 def : Pat<(v2f64 (scalar_to_vector (f64 (load ixaddr:$src)))),
3338 (v2f64 (COPY_TO_REGCLASS (DFLOADf64 ixaddr:$src), VSRC))>;
3339 def : Pat<(v2f64 (scalar_to_vector (f64 (load xaddr:$src)))),
3340 (v2f64 (COPY_TO_REGCLASS (XFLOADf64 xaddr:$src), VSRC))>;
3341 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), xaddr:$src),
3342 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
3343 sub_64), xaddr:$src)>;
3344 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), xaddr:$src),
3345 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
3346 sub_64), xaddr:$src)>;
3347 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), xaddr:$src),
3348 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), xaddr:$src)>;
3349 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), xaddr:$src),
3350 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), xaddr:$src)>;
3351 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), ixaddr:$src),
3352 (DFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
3353 sub_64), ixaddr:$src)>;
3354 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), ixaddr:$src),
3355 (DFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
3356 sub_64), ixaddr:$src)>;
3357 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), ixaddr:$src),
3358 (DFSTOREf64 (EXTRACT_SUBREG $A, sub_64), ixaddr:$src)>;
3359 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), ixaddr:$src),
3360 (DFSTOREf64 (EXTRACT_SUBREG $A, sub_64), ixaddr:$src)>;
3361 } // IsBigEndian, HasP9Vector
3364 let Predicates = [IsBigEndian, HasP9Vector] in {
3366 // (Un)Signed DWord vector extract -> QP
3367 def : Pat<(f128 (sint_to_fp (i64 (extractelt v2i64:$src, 0)))),
3368 (f128 (XSCVSDQP (COPY_TO_REGCLASS $src, VFRC)))>;
3369 def : Pat<(f128 (sint_to_fp (i64 (extractelt v2i64:$src, 1)))),
3371 (EXTRACT_SUBREG (XXPERMDI $src, $src, 3), sub_64)))>;
3372 def : Pat<(f128 (uint_to_fp (i64 (extractelt v2i64:$src, 0)))),
3373 (f128 (XSCVUDQP (COPY_TO_REGCLASS $src, VFRC)))>;
3374 def : Pat<(f128 (uint_to_fp (i64 (extractelt v2i64:$src, 1)))),
3376 (EXTRACT_SUBREG (XXPERMDI $src, $src, 3), sub_64)))>;
3378 // (Un)Signed Word vector extract -> QP
3379 def : Pat<(f128 (sint_to_fp (i32 (extractelt v4i32:$src, 1)))),
3380 (f128 (XSCVSDQP (EXTRACT_SUBREG (VEXTSW2D $src), sub_64)))>;
3381 foreach Idx = [0,2,3] in {
3382 def : Pat<(f128 (sint_to_fp (i32 (extractelt v4i32:$src, Idx)))),
3383 (f128 (XSCVSDQP (EXTRACT_SUBREG
3384 (VEXTSW2D (VSPLTW Idx, $src)), sub_64)))>;
3386 foreach Idx = 0-3 in {
3387 def : Pat<(f128 (uint_to_fp (i32 (extractelt v4i32:$src, Idx)))),
3388 (f128 (XSCVUDQP (XXEXTRACTUW $src, !shl(Idx, 2))))>;
3391 // (Un)Signed HWord vector extract -> QP
3392 foreach Idx = 0-7 in {
3393 def : Pat<(f128 (sint_to_fp
3395 (vector_extract v8i16:$src, Idx), i16)))),
3396 (f128 (XSCVSDQP (EXTRACT_SUBREG
3397 (VEXTSH2D (VEXTRACTUH !add(Idx, Idx), $src)),
3399 // The SDAG adds the `and` since an `i16` is being extracted as an `i32`.
3400 def : Pat<(f128 (uint_to_fp
3401 (and (i32 (vector_extract v8i16:$src, Idx)), 65535))),
3402 (f128 (XSCVUDQP (EXTRACT_SUBREG
3403 (VEXTRACTUH !add(Idx, Idx), $src), sub_64)))>;
3406 // (Un)Signed Byte vector extract -> QP
3407 foreach Idx = 0-15 in {
3408 def : Pat<(f128 (sint_to_fp
3409 (i32 (sext_inreg (vector_extract v16i8:$src, Idx),
3411 (f128 (XSCVSDQP (EXTRACT_SUBREG
3412 (VEXTSB2D (VEXTRACTUB Idx, $src)), sub_64)))>;
3413 def : Pat<(f128 (uint_to_fp
3414 (and (i32 (vector_extract v16i8:$src, Idx)), 255))),
3416 (EXTRACT_SUBREG (VEXTRACTUB Idx, $src), sub_64)))>;
3419 // Unsiged int in vsx register -> QP
3420 def : Pat<(f128 (uint_to_fp (i32 (PPCmfvsr f64:$src)))),
3422 (XXEXTRACTUW (SUBREG_TO_REG (i64 1), $src, sub_64), 4)))>;
3423 } // IsBigEndian, HasP9Vector
3425 let Predicates = [IsLittleEndian, HasP9Vector] in {
3427 // (Un)Signed DWord vector extract -> QP
3428 def : Pat<(f128 (sint_to_fp (i64 (extractelt v2i64:$src, 0)))),
3430 (EXTRACT_SUBREG (XXPERMDI $src, $src, 3), sub_64)))>;
3431 def : Pat<(f128 (sint_to_fp (i64 (extractelt v2i64:$src, 1)))),
3432 (f128 (XSCVSDQP (COPY_TO_REGCLASS $src, VFRC)))>;
3433 def : Pat<(f128 (uint_to_fp (i64 (extractelt v2i64:$src, 0)))),
3435 (EXTRACT_SUBREG (XXPERMDI $src, $src, 3), sub_64)))>;
3436 def : Pat<(f128 (uint_to_fp (i64 (extractelt v2i64:$src, 1)))),
3437 (f128 (XSCVUDQP (COPY_TO_REGCLASS $src, VFRC)))>;
3439 // (Un)Signed Word vector extract -> QP
3440 foreach Idx = [[0,3],[1,2],[3,0]] in {
3441 def : Pat<(f128 (sint_to_fp (i32 (extractelt v4i32:$src, !head(Idx))))),
3442 (f128 (XSCVSDQP (EXTRACT_SUBREG
3443 (VEXTSW2D (VSPLTW !head(!tail(Idx)), $src)),
3446 def : Pat<(f128 (sint_to_fp (i32 (extractelt v4i32:$src, 2)))),
3447 (f128 (XSCVSDQP (EXTRACT_SUBREG (VEXTSW2D $src), sub_64)))>;
3449 foreach Idx = [[0,12],[1,8],[2,4],[3,0]] in {
3450 def : Pat<(f128 (uint_to_fp (i32 (extractelt v4i32:$src, !head(Idx))))),
3451 (f128 (XSCVUDQP (XXEXTRACTUW $src, !head(!tail(Idx)))))>;
3454 // (Un)Signed HWord vector extract -> QP
3455 // The Nested foreach lists identifies the vector element and corresponding
3456 // register byte location.
3457 foreach Idx = [[0,14],[1,12],[2,10],[3,8],[4,6],[5,4],[6,2],[7,0]] in {
3458 def : Pat<(f128 (sint_to_fp
3460 (vector_extract v8i16:$src, !head(Idx)), i16)))),
3462 (EXTRACT_SUBREG (VEXTSH2D
3463 (VEXTRACTUH !head(!tail(Idx)), $src)),
3465 def : Pat<(f128 (uint_to_fp
3466 (and (i32 (vector_extract v8i16:$src, !head(Idx))),
3468 (f128 (XSCVUDQP (EXTRACT_SUBREG
3469 (VEXTRACTUH !head(!tail(Idx)), $src), sub_64)))>;
3472 // (Un)Signed Byte vector extract -> QP
3473 foreach Idx = [[0,15],[1,14],[2,13],[3,12],[4,11],[5,10],[6,9],[7,8],[8,7],
3474 [9,6],[10,5],[11,4],[12,3],[13,2],[14,1],[15,0]] in {
3475 def : Pat<(f128 (sint_to_fp
3477 (vector_extract v16i8:$src, !head(Idx)), i8)))),
3480 (VEXTSB2D (VEXTRACTUB !head(!tail(Idx)), $src)),
3482 def : Pat<(f128 (uint_to_fp
3483 (and (i32 (vector_extract v16i8:$src, !head(Idx))),
3487 (VEXTRACTUB !head(!tail(Idx)), $src), sub_64)))>;
3490 // Unsiged int in vsx register -> QP
3491 def : Pat<(f128 (uint_to_fp (i32 (PPCmfvsr f64:$src)))),
3493 (XXEXTRACTUW (SUBREG_TO_REG (i64 1), $src, sub_64), 8)))>;
3494 } // IsLittleEndian, HasP9Vector
3496 // Convert (Un)Signed DWord in memory -> QP
3497 def : Pat<(f128 (sint_to_fp (i64 (load xaddr:$src)))),
3498 (f128 (XSCVSDQP (LXSDX xaddr:$src)))>;
3499 def : Pat<(f128 (sint_to_fp (i64 (load ixaddr:$src)))),
3500 (f128 (XSCVSDQP (LXSD ixaddr:$src)))>;
3501 def : Pat<(f128 (uint_to_fp (i64 (load xaddr:$src)))),
3502 (f128 (XSCVUDQP (LXSDX xaddr:$src)))>;
3503 def : Pat<(f128 (uint_to_fp (i64 (load ixaddr:$src)))),
3504 (f128 (XSCVUDQP (LXSD ixaddr:$src)))>;
3506 // Convert Unsigned HWord in memory -> QP
3507 def : Pat<(f128 (uint_to_fp ScalarLoads.ZELi16)),
3508 (f128 (XSCVUDQP (LXSIHZX xaddr:$src)))>;
3510 // Convert Unsigned Byte in memory -> QP
3511 def : Pat<(f128 (uint_to_fp ScalarLoads.ZELi8)),
3512 (f128 (XSCVUDQP (LXSIBZX xoaddr:$src)))>;
3514 // Truncate & Convert QP -> (Un)Signed (D)Word.
3515 def : Pat<(i64 (fp_to_sint f128:$src)), (i64 (MFVRD (XSCVQPSDZ $src)))>;
3516 def : Pat<(i64 (fp_to_uint f128:$src)), (i64 (MFVRD (XSCVQPUDZ $src)))>;
3517 def : Pat<(i32 (fp_to_sint f128:$src)),
3518 (i32 (MFVSRWZ (COPY_TO_REGCLASS (XSCVQPSWZ $src), VFRC)))>;
3519 def : Pat<(i32 (fp_to_uint f128:$src)),
3520 (i32 (MFVSRWZ (COPY_TO_REGCLASS (XSCVQPUWZ $src), VFRC)))>;
3522 // Instructions for store(fptosi).
3523 // The 8-byte version is repeated here due to availability of D-Form STXSD.
3524 def : Pat<(PPCstore_scal_int_from_vsr
3525 (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)), xaddr:$dst, 8),
3526 (STXSDX (COPY_TO_REGCLASS (XSCVQPSDZ f128:$src), VFRC),
3528 def : Pat<(PPCstore_scal_int_from_vsr
3529 (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)), ixaddr:$dst, 8),
3530 (STXSD (COPY_TO_REGCLASS (XSCVQPSDZ f128:$src), VFRC),
3532 def : Pat<(PPCstore_scal_int_from_vsr
3533 (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)), xoaddr:$dst, 4),
3534 (STXSIWX (COPY_TO_REGCLASS (XSCVQPSWZ $src), VFRC), xoaddr:$dst)>;
3535 def : Pat<(PPCstore_scal_int_from_vsr
3536 (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)), xoaddr:$dst, 2),
3537 (STXSIHX (COPY_TO_REGCLASS (XSCVQPSWZ $src), VFRC), xoaddr:$dst)>;
3538 def : Pat<(PPCstore_scal_int_from_vsr
3539 (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)), xoaddr:$dst, 1),
3540 (STXSIBX (COPY_TO_REGCLASS (XSCVQPSWZ $src), VFRC), xoaddr:$dst)>;
3541 def : Pat<(PPCstore_scal_int_from_vsr
3542 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), xaddr:$dst, 8),
3543 (STXSDX (XSCVDPSXDS f64:$src), xaddr:$dst)>;
3544 def : Pat<(PPCstore_scal_int_from_vsr
3545 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), ixaddr:$dst, 8),
3546 (STXSD (XSCVDPSXDS f64:$src), ixaddr:$dst)>;
3547 def : Pat<(PPCstore_scal_int_from_vsr
3548 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), xoaddr:$dst, 2),
3549 (STXSIHX (XSCVDPSXWS f64:$src), xoaddr:$dst)>;
3550 def : Pat<(PPCstore_scal_int_from_vsr
3551 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), xoaddr:$dst, 1),
3552 (STXSIBX (XSCVDPSXWS f64:$src), xoaddr:$dst)>;
3554 // Instructions for store(fptoui).
3555 def : Pat<(PPCstore_scal_int_from_vsr
3556 (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)), xaddr:$dst, 8),
3557 (STXSDX (COPY_TO_REGCLASS (XSCVQPUDZ f128:$src), VFRC),
3559 def : Pat<(PPCstore_scal_int_from_vsr
3560 (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)), ixaddr:$dst, 8),
3561 (STXSD (COPY_TO_REGCLASS (XSCVQPUDZ f128:$src), VFRC),
3563 def : Pat<(PPCstore_scal_int_from_vsr
3564 (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)), xoaddr:$dst, 4),
3565 (STXSIWX (COPY_TO_REGCLASS (XSCVQPUWZ $src), VFRC), xoaddr:$dst)>;
3566 def : Pat<(PPCstore_scal_int_from_vsr
3567 (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)), xoaddr:$dst, 2),
3568 (STXSIHX (COPY_TO_REGCLASS (XSCVQPUWZ $src), VFRC), xoaddr:$dst)>;
3569 def : Pat<(PPCstore_scal_int_from_vsr
3570 (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)), xoaddr:$dst, 1),
3571 (STXSIBX (COPY_TO_REGCLASS (XSCVQPUWZ $src), VFRC), xoaddr:$dst)>;
3572 def : Pat<(PPCstore_scal_int_from_vsr
3573 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), xaddr:$dst, 8),
3574 (STXSDX (XSCVDPUXDS f64:$src), xaddr:$dst)>;
3575 def : Pat<(PPCstore_scal_int_from_vsr
3576 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), ixaddr:$dst, 8),
3577 (STXSD (XSCVDPUXDS f64:$src), ixaddr:$dst)>;
3578 def : Pat<(PPCstore_scal_int_from_vsr
3579 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), xoaddr:$dst, 2),
3580 (STXSIHX (XSCVDPUXWS f64:$src), xoaddr:$dst)>;
3581 def : Pat<(PPCstore_scal_int_from_vsr
3582 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), xoaddr:$dst, 1),
3583 (STXSIBX (XSCVDPUXWS f64:$src), xoaddr:$dst)>;
3585 // Round & Convert QP -> DP/SP
3586 def : Pat<(f64 (fpround f128:$src)), (f64 (XSCVQPDP $src))>;
3587 def : Pat<(f32 (fpround f128:$src)), (f32 (XSRSP (XSCVQPDPO $src)))>;
3590 def : Pat<(f128 (fpextend f32:$src)),
3591 (f128 (XSCVDPQP (COPY_TO_REGCLASS $src, VFRC)))>;
3593 } // end HasP9Vector, AddedComplexity
3595 let AddedComplexity = 400 in {
3596 let Predicates = [IsISA3_0, HasP9Vector, HasDirectMove, IsBigEndian] in {
3597 def : Pat<(f128 (PPCbuild_fp128 i64:$rB, i64:$rA)),
3598 (f128 (COPY_TO_REGCLASS (MTVSRDD $rB, $rA), VRRC))>;
3600 let Predicates = [IsISA3_0, HasP9Vector, HasDirectMove, IsLittleEndian] in {
3601 def : Pat<(f128 (PPCbuild_fp128 i64:$rA, i64:$rB)),
3602 (f128 (COPY_TO_REGCLASS (MTVSRDD $rB, $rA), VRRC))>;
3606 let Predicates = [HasP9Vector] in {
3607 let mayStore = 1 in {
3608 def SPILLTOVSR_STX : PseudoXFormMemOp<(outs),
3609 (ins spilltovsrrc:$XT, memrr:$dst),
3610 "#SPILLTOVSR_STX", []>;
3611 def SPILLTOVSR_ST : PPCPostRAExpPseudo<(outs), (ins spilltovsrrc:$XT, memrix:$dst),
3612 "#SPILLTOVSR_ST", []>;
3614 let mayLoad = 1 in {
3615 def SPILLTOVSR_LDX : PseudoXFormMemOp<(outs spilltovsrrc:$XT),
3617 "#SPILLTOVSR_LDX", []>;
3618 def SPILLTOVSR_LD : PPCPostRAExpPseudo<(outs spilltovsrrc:$XT), (ins memrix:$src),
3619 "#SPILLTOVSR_LD", []>;
3623 // Integer extend helper dags 32 -> 64
3625 dag A = (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $A, sub_32);
3626 dag B = (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $B, sub_32);
3627 dag C = (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $C, sub_32);
3628 dag D = (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $D, sub_32);
3632 dag A0 = (f32 (fpround (f64 (extractelt v2f64:$A, 0))));
3633 dag A1 = (f32 (fpround (f64 (extractelt v2f64:$A, 1))));
3634 dag B0 = (f32 (fpround (f64 (extractelt v2f64:$B, 0))));
3635 dag B1 = (f32 (fpround (f64 (extractelt v2f64:$B, 1))));
3639 dag A0S = (i32 (PPCmfvsr (f64 (PPCfctiwz (f64 (extractelt v2f64:$A, 0))))));
3640 dag A1S = (i32 (PPCmfvsr (f64 (PPCfctiwz (f64 (extractelt v2f64:$A, 1))))));
3641 dag B0S = (i32 (PPCmfvsr (f64 (PPCfctiwz (f64 (extractelt v2f64:$B, 0))))));
3642 dag B1S = (i32 (PPCmfvsr (f64 (PPCfctiwz (f64 (extractelt v2f64:$B, 1))))));
3643 dag A0U = (i32 (PPCmfvsr (f64 (PPCfctiwuz (f64 (extractelt v2f64:$A, 0))))));
3644 dag A1U = (i32 (PPCmfvsr (f64 (PPCfctiwuz (f64 (extractelt v2f64:$A, 1))))));
3645 dag B0U = (i32 (PPCmfvsr (f64 (PPCfctiwuz (f64 (extractelt v2f64:$B, 0))))));
3646 dag B1U = (i32 (PPCmfvsr (f64 (PPCfctiwuz (f64 (extractelt v2f64:$B, 1))))));
3650 dag LE_A0 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 0)), i8));
3651 dag LE_A1 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 4)), i8));
3652 dag LE_A2 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 8)), i8));
3653 dag LE_A3 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 12)), i8));
3654 dag BE_A0 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 3)), i8));
3655 dag BE_A1 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 7)), i8));
3656 dag BE_A2 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 11)), i8));
3657 dag BE_A3 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 15)), i8));
3661 dag LE_A0 = (i64 (sext_inreg
3662 (i64 (anyext (i32 (vector_extract v16i8:$A, 0)))), i8));
3663 dag LE_A1 = (i64 (sext_inreg
3664 (i64 (anyext (i32 (vector_extract v16i8:$A, 8)))), i8));
3665 dag BE_A0 = (i64 (sext_inreg
3666 (i64 (anyext (i32 (vector_extract v16i8:$A, 7)))), i8));
3667 dag BE_A1 = (i64 (sext_inreg
3668 (i64 (anyext (i32 (vector_extract v16i8:$A, 15)))), i8));
3672 dag LE_A0 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 0)), i16));
3673 dag LE_A1 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 2)), i16));
3674 dag LE_A2 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 4)), i16));
3675 dag LE_A3 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 6)), i16));
3676 dag BE_A0 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 1)), i16));
3677 dag BE_A1 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 3)), i16));
3678 dag BE_A2 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 5)), i16));
3679 dag BE_A3 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 7)), i16));
3683 dag LE_A0 = (i64 (sext_inreg
3684 (i64 (anyext (i32 (vector_extract v8i16:$A, 0)))), i16));
3685 dag LE_A1 = (i64 (sext_inreg
3686 (i64 (anyext (i32 (vector_extract v8i16:$A, 4)))), i16));
3687 dag BE_A0 = (i64 (sext_inreg
3688 (i64 (anyext (i32 (vector_extract v8i16:$A, 3)))), i16));
3689 dag BE_A1 = (i64 (sext_inreg
3690 (i64 (anyext (i32 (vector_extract v8i16:$A, 7)))), i16));
3694 dag LE_A0 = (i64 (sext (i32 (vector_extract v4i32:$A, 0))));
3695 dag LE_A1 = (i64 (sext (i32 (vector_extract v4i32:$A, 2))));
3696 dag BE_A0 = (i64 (sext (i32 (vector_extract v4i32:$A, 1))));
3697 dag BE_A1 = (i64 (sext (i32 (vector_extract v4i32:$A, 3))));
3701 dag A = (i32 (PPCmfvsr (PPCfctiwz (f64 (extloadf32 xoaddr:$A)))));
3704 dag A = (i32 (PPCmfvsr (PPCfctiwuz (f64 (extloadf32 xoaddr:$A)))));
3707 dag A = (i64 (PPCmfvsr (PPCfctidz (f64 (extloadf32 xoaddr:$A)))));
3709 def FltToLongLoadP9 {
3710 dag A = (i64 (PPCmfvsr (PPCfctidz (f64 (extloadf32 ixaddr:$A)))));
3712 def FltToULongLoad {
3713 dag A = (i64 (PPCmfvsr (PPCfctiduz (f64 (extloadf32 xoaddr:$A)))));
3715 def FltToULongLoadP9 {
3716 dag A = (i64 (PPCmfvsr (PPCfctiduz (f64 (extloadf32 ixaddr:$A)))));
3719 dag A = (i64 (PPCmfvsr (f64 (PPCfctidz (fpextend f32:$A)))));
3722 dag A = (i64 (PPCmfvsr (f64 (PPCfctiduz (fpextend f32:$A)))));
3725 dag A = (i32 (PPCmfvsr (f64 (PPCfctiwz f64:$A))));
3726 dag B = (i32 (PPCmfvsr (f64 (PPCfctiwz f64:$B))));
3727 dag C = (i32 (PPCmfvsr (f64 (PPCfctiwz f64:$C))));
3728 dag D = (i32 (PPCmfvsr (f64 (PPCfctiwz f64:$D))));
3731 dag A = (i32 (PPCmfvsr (f64 (PPCfctiwuz f64:$A))));
3732 dag B = (i32 (PPCmfvsr (f64 (PPCfctiwuz f64:$B))));
3733 dag C = (i32 (PPCmfvsr (f64 (PPCfctiwuz f64:$C))));
3734 dag D = (i32 (PPCmfvsr (f64 (PPCfctiwuz f64:$D))));
3737 dag A = (i64 (PPCmfvsr (f64 (PPCfctidz f64:$A))));
3740 dag A = (i64 (PPCmfvsr (f64 (PPCfctiduz f64:$A))));
3743 dag A = (i32 (PPCmfvsr (PPCfctiwz (f64 (load xoaddr:$A)))));
3745 def DblToIntLoadP9 {
3746 dag A = (i32 (PPCmfvsr (PPCfctiwz (f64 (load ixaddr:$A)))));
3749 dag A = (i32 (PPCmfvsr (PPCfctiwuz (f64 (load xoaddr:$A)))));
3751 def DblToUIntLoadP9 {
3752 dag A = (i32 (PPCmfvsr (PPCfctiwuz (f64 (load ixaddr:$A)))));
3755 dag A = (i64 (PPCmfvsr (PPCfctidz (f64 (load xoaddr:$A)))));
3757 def DblToULongLoad {
3758 dag A = (i64 (PPCmfvsr (PPCfctiduz (f64 (load xoaddr:$A)))));
3761 // FP merge dags (for f32 -> v4f32)
3763 dag AC = (XVCVDPSP (XXPERMDI (COPY_TO_REGCLASS $A, VSRC),
3764 (COPY_TO_REGCLASS $C, VSRC), 0));
3765 dag BD = (XVCVDPSP (XXPERMDI (COPY_TO_REGCLASS $B, VSRC),
3766 (COPY_TO_REGCLASS $D, VSRC), 0));
3767 dag ABhToFlt = (XVCVDPSP (XXPERMDI $A, $B, 0));
3768 dag ABlToFlt = (XVCVDPSP (XXPERMDI $A, $B, 3));
3769 dag BAhToFlt = (XVCVDPSP (XXPERMDI $B, $A, 0));
3770 dag BAlToFlt = (XVCVDPSP (XXPERMDI $B, $A, 3));
3773 // Word-element merge dags - conversions from f64 to i32 merged into vectors.
3775 // For big endian, we merge low and hi doublewords (A, B).
3776 dag A0B0 = (v2f64 (XXPERMDI v2f64:$A, v2f64:$B, 0));
3777 dag A1B1 = (v2f64 (XXPERMDI v2f64:$A, v2f64:$B, 3));
3778 dag CVA1B1S = (v4i32 (XVCVDPSXWS A1B1));
3779 dag CVA0B0S = (v4i32 (XVCVDPSXWS A0B0));
3780 dag CVA1B1U = (v4i32 (XVCVDPUXWS A1B1));
3781 dag CVA0B0U = (v4i32 (XVCVDPUXWS A0B0));
3783 // For little endian, we merge low and hi doublewords (B, A).
3784 dag B1A1 = (v2f64 (XXPERMDI v2f64:$B, v2f64:$A, 0));
3785 dag B0A0 = (v2f64 (XXPERMDI v2f64:$B, v2f64:$A, 3));
3786 dag CVB1A1S = (v4i32 (XVCVDPSXWS B1A1));
3787 dag CVB0A0S = (v4i32 (XVCVDPSXWS B0A0));
3788 dag CVB1A1U = (v4i32 (XVCVDPUXWS B1A1));
3789 dag CVB0A0U = (v4i32 (XVCVDPUXWS B0A0));
3791 // For big endian, we merge hi doublewords of (A, C) and (B, D), convert
3793 dag AC = (v2f64 (XXPERMDI (COPY_TO_REGCLASS f64:$A, VSRC),
3794 (COPY_TO_REGCLASS f64:$C, VSRC), 0));
3795 dag BD = (v2f64 (XXPERMDI (COPY_TO_REGCLASS f64:$B, VSRC),
3796 (COPY_TO_REGCLASS f64:$D, VSRC), 0));
3797 dag CVACS = (v4i32 (XVCVDPSXWS AC));
3798 dag CVBDS = (v4i32 (XVCVDPSXWS BD));
3799 dag CVACU = (v4i32 (XVCVDPUXWS AC));
3800 dag CVBDU = (v4i32 (XVCVDPUXWS BD));
3802 // For little endian, we merge hi doublewords of (D, B) and (C, A), convert
3804 dag DB = (v2f64 (XXPERMDI (COPY_TO_REGCLASS f64:$D, VSRC),
3805 (COPY_TO_REGCLASS f64:$B, VSRC), 0));
3806 dag CA = (v2f64 (XXPERMDI (COPY_TO_REGCLASS f64:$C, VSRC),
3807 (COPY_TO_REGCLASS f64:$A, VSRC), 0));
3808 dag CVDBS = (v4i32 (XVCVDPSXWS DB));
3809 dag CVCAS = (v4i32 (XVCVDPSXWS CA));
3810 dag CVDBU = (v4i32 (XVCVDPUXWS DB));
3811 dag CVCAU = (v4i32 (XVCVDPUXWS CA));
3814 // Patterns for BUILD_VECTOR nodes.
3815 let AddedComplexity = 400 in {
3817 let Predicates = [HasVSX] in {
3818 // Build vectors of floating point converted to i32.
3819 def : Pat<(v4i32 (build_vector DblToInt.A, DblToInt.A,
3820 DblToInt.A, DblToInt.A)),
3821 (v4i32 (XXSPLTW (COPY_TO_REGCLASS (XSCVDPSXWS $A), VSRC), 1))>;
3822 def : Pat<(v4i32 (build_vector DblToUInt.A, DblToUInt.A,
3823 DblToUInt.A, DblToUInt.A)),
3824 (v4i32 (XXSPLTW (COPY_TO_REGCLASS (XSCVDPUXWS $A), VSRC), 1))>;
3825 def : Pat<(v2i64 (build_vector DblToLong.A, DblToLong.A)),
3826 (v2i64 (XXPERMDI (COPY_TO_REGCLASS (XSCVDPSXDS $A), VSRC),
3827 (COPY_TO_REGCLASS (XSCVDPSXDS $A), VSRC), 0))>;
3828 def : Pat<(v2i64 (build_vector DblToULong.A, DblToULong.A)),
3829 (v2i64 (XXPERMDI (COPY_TO_REGCLASS (XSCVDPUXDS $A), VSRC),
3830 (COPY_TO_REGCLASS (XSCVDPUXDS $A), VSRC), 0))>;
3831 def : Pat<(v4i32 (scalar_to_vector FltToIntLoad.A)),
3832 (v4i32 (XXSPLTW (COPY_TO_REGCLASS
3833 (XSCVDPSXWSs (XFLOADf32 xoaddr:$A)), VSRC), 1))>;
3834 def : Pat<(v4i32 (scalar_to_vector FltToUIntLoad.A)),
3835 (v4i32 (XXSPLTW (COPY_TO_REGCLASS
3836 (XSCVDPUXWSs (XFLOADf32 xoaddr:$A)), VSRC), 1))>;
3837 def : Pat<(v4f32 (build_vector f32:$A, f32:$A, f32:$A, f32:$A)),
3838 (v4f32 (XXSPLTW (v4f32 (XSCVDPSPN $A)), 0))>;
3840 // Build vectors of floating point converted to i64.
3841 def : Pat<(v2i64 (build_vector FltToLong.A, FltToLong.A)),
3843 (COPY_TO_REGCLASS (XSCVDPSXDSs $A), VSFRC), 0))>;
3844 def : Pat<(v2i64 (build_vector FltToULong.A, FltToULong.A)),
3846 (COPY_TO_REGCLASS (XSCVDPUXDSs $A), VSFRC), 0))>;
3847 def : Pat<(v2i64 (scalar_to_vector DblToLongLoad.A)),
3848 (v2i64 (XVCVDPSXDS (LXVDSX xoaddr:$A)))>;
3849 def : Pat<(v2i64 (scalar_to_vector DblToULongLoad.A)),
3850 (v2i64 (XVCVDPUXDS (LXVDSX xoaddr:$A)))>;
3853 let Predicates = [HasVSX, NoP9Vector] in {
3854 // Load-and-splat with fp-to-int conversion (using X-Form VSX/FP loads).
3855 def : Pat<(v4i32 (scalar_to_vector DblToIntLoad.A)),
3856 (v4i32 (XXSPLTW (COPY_TO_REGCLASS
3857 (XSCVDPSXWS (XFLOADf64 xoaddr:$A)), VSRC), 1))>;
3858 def : Pat<(v4i32 (scalar_to_vector DblToUIntLoad.A)),
3859 (v4i32 (XXSPLTW (COPY_TO_REGCLASS
3860 (XSCVDPUXWS (XFLOADf64 xoaddr:$A)), VSRC), 1))>;
3861 def : Pat<(v2i64 (scalar_to_vector FltToLongLoad.A)),
3862 (v2i64 (XXPERMDIs (XSCVDPSXDS (COPY_TO_REGCLASS
3863 (XFLOADf32 xoaddr:$A), VSFRC)), 0))>;
3864 def : Pat<(v2i64 (scalar_to_vector FltToULongLoad.A)),
3865 (v2i64 (XXPERMDIs (XSCVDPUXDS (COPY_TO_REGCLASS
3866 (XFLOADf32 xoaddr:$A), VSFRC)), 0))>;
3869 let Predicates = [IsBigEndian, HasP8Vector] in {
3870 def : Pat<DWToSPExtractConv.BVU,
3871 (v4f32 (VPKUDUM (XXSLDWI (XVCVUXDSP $S1), (XVCVUXDSP $S1), 3),
3872 (XXSLDWI (XVCVUXDSP $S2), (XVCVUXDSP $S2), 3)))>;
3873 def : Pat<DWToSPExtractConv.BVS,
3874 (v4f32 (VPKUDUM (XXSLDWI (XVCVSXDSP $S1), (XVCVSXDSP $S1), 3),
3875 (XXSLDWI (XVCVSXDSP $S2), (XVCVSXDSP $S2), 3)))>;
3876 def : Pat<(store (i32 (extractelt v4i32:$A, 1)), xoaddr:$src),
3877 (STIWX (EXTRACT_SUBREG $A, sub_64), xoaddr:$src)>;
3878 def : Pat<(store (f32 (extractelt v4f32:$A, 1)), xoaddr:$src),
3879 (STIWX (EXTRACT_SUBREG $A, sub_64), xoaddr:$src)>;
3881 // Elements in a register on a BE system are in order <0, 1, 2, 3>.
3882 // The store instructions store the second word from the left.
3883 // So to align element zero, we need to modulo-left-shift by 3 words.
3884 // Similar logic applies for elements 2 and 3.
3885 foreach Idx = [ [0,3], [2,1], [3,2] ] in {
3886 def : Pat<(store (i32 (extractelt v4i32:$A, !head(Idx))), xoaddr:$src),
3887 (STIWX (EXTRACT_SUBREG (XXSLDWI $A, $A, !head(!tail(Idx))),
3888 sub_64), xoaddr:$src)>;
3889 def : Pat<(store (f32 (extractelt v4f32:$A, !head(Idx))), xoaddr:$src),
3890 (STIWX (EXTRACT_SUBREG (XXSLDWI $A, $A, !head(!tail(Idx))),
3891 sub_64), xoaddr:$src)>;
3895 let Predicates = [HasP8Vector, IsBigEndian, NoP9Vector] in {
3896 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), xoaddr:$src),
3897 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), xoaddr:$src)>;
3898 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), xoaddr:$src),
3899 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), xoaddr:$src)>;
3900 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), xoaddr:$src),
3901 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2), sub_64),
3903 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), xoaddr:$src),
3904 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2), sub_64),
3908 // Big endian, available on all targets with VSX
3909 let Predicates = [IsBigEndian, HasVSX] in {
3910 def : Pat<(v2f64 (build_vector f64:$A, f64:$B)),
3912 (COPY_TO_REGCLASS $A, VSRC),
3913 (COPY_TO_REGCLASS $B, VSRC), 0))>;
3915 def : Pat<(v4f32 (build_vector f32:$A, f32:$B, f32:$C, f32:$D)),
3916 (VMRGEW MrgFP.AC, MrgFP.BD)>;
3917 def : Pat<(v4f32 (build_vector DblToFlt.A0, DblToFlt.A1,
3918 DblToFlt.B0, DblToFlt.B1)),
3919 (v4f32 (VMRGEW MrgFP.ABhToFlt, MrgFP.ABlToFlt))>;
3921 // Convert 4 doubles to a vector of ints.
3922 def : Pat<(v4i32 (build_vector DblToInt.A, DblToInt.B,
3923 DblToInt.C, DblToInt.D)),
3924 (v4i32 (VMRGEW MrgWords.CVACS, MrgWords.CVBDS))>;
3925 def : Pat<(v4i32 (build_vector DblToUInt.A, DblToUInt.B,
3926 DblToUInt.C, DblToUInt.D)),
3927 (v4i32 (VMRGEW MrgWords.CVACU, MrgWords.CVBDU))>;
3928 def : Pat<(v4i32 (build_vector ExtDbl.A0S, ExtDbl.A1S,
3929 ExtDbl.B0S, ExtDbl.B1S)),
3930 (v4i32 (VMRGEW MrgWords.CVA0B0S, MrgWords.CVA1B1S))>;
3931 def : Pat<(v4i32 (build_vector ExtDbl.A0U, ExtDbl.A1U,
3932 ExtDbl.B0U, ExtDbl.B1U)),
3933 (v4i32 (VMRGEW MrgWords.CVA0B0U, MrgWords.CVA1B1U))>;
3936 let Predicates = [IsLittleEndian, HasP8Vector] in {
3937 def : Pat<DWToSPExtractConv.BVU,
3938 (v4f32 (VPKUDUM (XXSLDWI (XVCVUXDSP $S2), (XVCVUXDSP $S2), 3),
3939 (XXSLDWI (XVCVUXDSP $S1), (XVCVUXDSP $S1), 3)))>;
3940 def : Pat<DWToSPExtractConv.BVS,
3941 (v4f32 (VPKUDUM (XXSLDWI (XVCVSXDSP $S2), (XVCVSXDSP $S2), 3),
3942 (XXSLDWI (XVCVSXDSP $S1), (XVCVSXDSP $S1), 3)))>;
3943 def : Pat<(store (i32 (extractelt v4i32:$A, 2)), xoaddr:$src),
3944 (STIWX (EXTRACT_SUBREG $A, sub_64), xoaddr:$src)>;
3945 def : Pat<(store (f32 (extractelt v4f32:$A, 2)), xoaddr:$src),
3946 (STIWX (EXTRACT_SUBREG $A, sub_64), xoaddr:$src)>;
3948 // Elements in a register on a LE system are in order <3, 2, 1, 0>.
3949 // The store instructions store the second word from the left.
3950 // So to align element 3, we need to modulo-left-shift by 3 words.
3951 // Similar logic applies for elements 0 and 1.
3952 foreach Idx = [ [0,2], [1,1], [3,3] ] in {
3953 def : Pat<(store (i32 (extractelt v4i32:$A, !head(Idx))), xoaddr:$src),
3954 (STIWX (EXTRACT_SUBREG (XXSLDWI $A, $A, !head(!tail(Idx))),
3955 sub_64), xoaddr:$src)>;
3956 def : Pat<(store (f32 (extractelt v4f32:$A, !head(Idx))), xoaddr:$src),
3957 (STIWX (EXTRACT_SUBREG (XXSLDWI $A, $A, !head(!tail(Idx))),
3958 sub_64), xoaddr:$src)>;
3962 let Predicates = [HasP8Vector, IsLittleEndian, NoP9Vector] in {
3963 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), xoaddr:$src),
3964 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2), sub_64),
3966 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), xoaddr:$src),
3967 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2), sub_64),
3969 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), xoaddr:$src),
3970 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), xoaddr:$src)>;
3971 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), xoaddr:$src),
3972 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), xoaddr:$src)>;
3975 let Predicates = [IsLittleEndian, HasVSX] in {
3976 // Little endian, available on all targets with VSX
3977 def : Pat<(v2f64 (build_vector f64:$A, f64:$B)),
3979 (COPY_TO_REGCLASS $B, VSRC),
3980 (COPY_TO_REGCLASS $A, VSRC), 0))>;
3982 def : Pat<(v4f32 (build_vector f32:$D, f32:$C, f32:$B, f32:$A)),
3983 (VMRGEW MrgFP.AC, MrgFP.BD)>;
3984 def : Pat<(v4f32 (build_vector DblToFlt.A0, DblToFlt.A1,
3985 DblToFlt.B0, DblToFlt.B1)),
3986 (v4f32 (VMRGEW MrgFP.BAhToFlt, MrgFP.BAlToFlt))>;
3988 // Convert 4 doubles to a vector of ints.
3989 def : Pat<(v4i32 (build_vector DblToInt.A, DblToInt.B,
3990 DblToInt.C, DblToInt.D)),
3991 (v4i32 (VMRGEW MrgWords.CVDBS, MrgWords.CVCAS))>;
3992 def : Pat<(v4i32 (build_vector DblToUInt.A, DblToUInt.B,
3993 DblToUInt.C, DblToUInt.D)),
3994 (v4i32 (VMRGEW MrgWords.CVDBU, MrgWords.CVCAU))>;
3995 def : Pat<(v4i32 (build_vector ExtDbl.A0S, ExtDbl.A1S,
3996 ExtDbl.B0S, ExtDbl.B1S)),
3997 (v4i32 (VMRGEW MrgWords.CVB1A1S, MrgWords.CVB0A0S))>;
3998 def : Pat<(v4i32 (build_vector ExtDbl.A0U, ExtDbl.A1U,
3999 ExtDbl.B0U, ExtDbl.B1U)),
4000 (v4i32 (VMRGEW MrgWords.CVB1A1U, MrgWords.CVB0A0U))>;
4003 let Predicates = [HasDirectMove] in {
4004 // Endianness-neutral constant splat on P8 and newer targets. The reason
4005 // for this pattern is that on targets with direct moves, we don't expand
4006 // BUILD_VECTOR nodes for v4i32.
4007 def : Pat<(v4i32 (build_vector immSExt5NonZero:$A, immSExt5NonZero:$A,
4008 immSExt5NonZero:$A, immSExt5NonZero:$A)),
4009 (v4i32 (VSPLTISW imm:$A))>;
4012 let Predicates = [IsBigEndian, HasDirectMove, NoP9Vector] in {
4013 // Big endian integer vectors using direct moves.
4014 def : Pat<(v2i64 (build_vector i64:$A, i64:$B)),
4016 (COPY_TO_REGCLASS (MTVSRD $A), VSRC),
4017 (COPY_TO_REGCLASS (MTVSRD $B), VSRC), 0))>;
4018 def : Pat<(v4i32 (build_vector i32:$A, i32:$B, i32:$C, i32:$D)),
4021 (MTVSRD (RLDIMI AnyExts.B, AnyExts.A, 32, 0)), VSRC),
4023 (MTVSRD (RLDIMI AnyExts.D, AnyExts.C, 32, 0)), VSRC), 0)>;
4024 def : Pat<(v4i32 (build_vector i32:$A, i32:$A, i32:$A, i32:$A)),
4025 (XXSPLTW (COPY_TO_REGCLASS (MTVSRWZ $A), VSRC), 1)>;
4028 let Predicates = [IsLittleEndian, HasDirectMove, NoP9Vector] in {
4029 // Little endian integer vectors using direct moves.
4030 def : Pat<(v2i64 (build_vector i64:$A, i64:$B)),
4032 (COPY_TO_REGCLASS (MTVSRD $B), VSRC),
4033 (COPY_TO_REGCLASS (MTVSRD $A), VSRC), 0))>;
4034 def : Pat<(v4i32 (build_vector i32:$A, i32:$B, i32:$C, i32:$D)),
4037 (MTVSRD (RLDIMI AnyExts.C, AnyExts.D, 32, 0)), VSRC),
4039 (MTVSRD (RLDIMI AnyExts.A, AnyExts.B, 32, 0)), VSRC), 0)>;
4040 def : Pat<(v4i32 (build_vector i32:$A, i32:$A, i32:$A, i32:$A)),
4041 (XXSPLTW (COPY_TO_REGCLASS (MTVSRWZ $A), VSRC), 1)>;
4044 let Predicates = [HasP9Vector] in {
4045 // Endianness-neutral patterns for const splats with ISA 3.0 instructions.
4046 def : Pat<(v4i32 (scalar_to_vector i32:$A)),
4047 (v4i32 (MTVSRWS $A))>;
4048 def : Pat<(v4i32 (build_vector i32:$A, i32:$A, i32:$A, i32:$A)),
4049 (v4i32 (MTVSRWS $A))>;
4050 def : Pat<(v16i8 (build_vector immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A,
4051 immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A,
4052 immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A,
4053 immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A,
4054 immAnyExt8:$A, immAnyExt8:$A, immAnyExt8:$A,
4056 (v16i8 (COPY_TO_REGCLASS (XXSPLTIB imm:$A), VSRC))>;
4057 def : Pat<(v16i8 immAllOnesV),
4058 (v16i8 (COPY_TO_REGCLASS (XXSPLTIB 255), VSRC))>;
4059 def : Pat<(v8i16 immAllOnesV),
4060 (v8i16 (COPY_TO_REGCLASS (XXSPLTIB 255), VSRC))>;
4061 def : Pat<(v4i32 immAllOnesV),
4062 (v4i32 (XXSPLTIB 255))>;
4063 def : Pat<(v2i64 immAllOnesV),
4064 (v2i64 (XXSPLTIB 255))>;
4065 def : Pat<(v4i32 (scalar_to_vector FltToIntLoad.A)),
4066 (v4i32 (XVCVSPSXWS (LXVWSX xoaddr:$A)))>;
4067 def : Pat<(v4i32 (scalar_to_vector FltToUIntLoad.A)),
4068 (v4i32 (XVCVSPUXWS (LXVWSX xoaddr:$A)))>;
4069 def : Pat<(v4i32 (scalar_to_vector DblToIntLoadP9.A)),
4070 (v4i32 (XXSPLTW (COPY_TO_REGCLASS
4071 (XSCVDPSXWS (DFLOADf64 ixaddr:$A)), VSRC), 1))>;
4072 def : Pat<(v4i32 (scalar_to_vector DblToUIntLoadP9.A)),
4073 (v4i32 (XXSPLTW (COPY_TO_REGCLASS
4074 (XSCVDPUXWS (DFLOADf64 ixaddr:$A)), VSRC), 1))>;
4075 def : Pat<(v2i64 (scalar_to_vector FltToLongLoadP9.A)),
4076 (v2i64 (XXPERMDIs (XSCVDPSXDS (COPY_TO_REGCLASS
4077 (DFLOADf32 ixaddr:$A),
4079 def : Pat<(v2i64 (scalar_to_vector FltToULongLoadP9.A)),
4080 (v2i64 (XXPERMDIs (XSCVDPUXDS (COPY_TO_REGCLASS
4081 (DFLOADf32 ixaddr:$A),
4085 let Predicates = [IsISA3_0, HasDirectMove, IsBigEndian] in {
4086 def : Pat<(i64 (extractelt v2i64:$A, 1)),
4087 (i64 (MFVSRLD $A))>;
4088 // Better way to build integer vectors if we have MTVSRDD. Big endian.
4089 def : Pat<(v2i64 (build_vector i64:$rB, i64:$rA)),
4090 (v2i64 (MTVSRDD $rB, $rA))>;
4091 def : Pat<(v4i32 (build_vector i32:$A, i32:$B, i32:$C, i32:$D)),
4093 (RLDIMI AnyExts.B, AnyExts.A, 32, 0),
4094 (RLDIMI AnyExts.D, AnyExts.C, 32, 0))>;
4097 let Predicates = [IsISA3_0, HasDirectMove, IsLittleEndian] in {
4098 def : Pat<(i64 (extractelt v2i64:$A, 0)),
4099 (i64 (MFVSRLD $A))>;
4100 // Better way to build integer vectors if we have MTVSRDD. Little endian.
4101 def : Pat<(v2i64 (build_vector i64:$rA, i64:$rB)),
4102 (v2i64 (MTVSRDD $rB, $rA))>;
4103 def : Pat<(v4i32 (build_vector i32:$A, i32:$B, i32:$C, i32:$D)),
4105 (RLDIMI AnyExts.C, AnyExts.D, 32, 0),
4106 (RLDIMI AnyExts.A, AnyExts.B, 32, 0))>;
4108 // P9 Altivec instructions that can be used to build vectors.
4109 // Adding them to PPCInstrVSX.td rather than PPCAltivecVSX.td to compete
4110 // with complexities of existing build vector patterns in this file.
4111 let Predicates = [HasP9Altivec, IsLittleEndian] in {
4112 def : Pat<(v2i64 (build_vector WordToDWord.LE_A0, WordToDWord.LE_A1)),
4113 (v2i64 (VEXTSW2D $A))>;
4114 def : Pat<(v2i64 (build_vector HWordToDWord.LE_A0, HWordToDWord.LE_A1)),
4115 (v2i64 (VEXTSH2D $A))>;
4116 def : Pat<(v4i32 (build_vector HWordToWord.LE_A0, HWordToWord.LE_A1,
4117 HWordToWord.LE_A2, HWordToWord.LE_A3)),
4118 (v4i32 (VEXTSH2W $A))>;
4119 def : Pat<(v4i32 (build_vector ByteToWord.LE_A0, ByteToWord.LE_A1,
4120 ByteToWord.LE_A2, ByteToWord.LE_A3)),
4121 (v4i32 (VEXTSB2W $A))>;
4122 def : Pat<(v2i64 (build_vector ByteToDWord.LE_A0, ByteToDWord.LE_A1)),
4123 (v2i64 (VEXTSB2D $A))>;
4126 let Predicates = [HasP9Altivec, IsBigEndian] in {
4127 def : Pat<(v2i64 (build_vector WordToDWord.BE_A0, WordToDWord.BE_A1)),
4128 (v2i64 (VEXTSW2D $A))>;
4129 def : Pat<(v2i64 (build_vector HWordToDWord.BE_A0, HWordToDWord.BE_A1)),
4130 (v2i64 (VEXTSH2D $A))>;
4131 def : Pat<(v4i32 (build_vector HWordToWord.BE_A0, HWordToWord.BE_A1,
4132 HWordToWord.BE_A2, HWordToWord.BE_A3)),
4133 (v4i32 (VEXTSH2W $A))>;
4134 def : Pat<(v4i32 (build_vector ByteToWord.BE_A0, ByteToWord.BE_A1,
4135 ByteToWord.BE_A2, ByteToWord.BE_A3)),
4136 (v4i32 (VEXTSB2W $A))>;
4137 def : Pat<(v2i64 (build_vector ByteToDWord.BE_A0, ByteToDWord.BE_A1)),
4138 (v2i64 (VEXTSB2D $A))>;
4141 let Predicates = [HasP9Altivec] in {
4142 def: Pat<(v2i64 (PPCSExtVElems v16i8:$A)),
4143 (v2i64 (VEXTSB2D $A))>;
4144 def: Pat<(v2i64 (PPCSExtVElems v8i16:$A)),
4145 (v2i64 (VEXTSH2D $A))>;
4146 def: Pat<(v2i64 (PPCSExtVElems v4i32:$A)),
4147 (v2i64 (VEXTSW2D $A))>;
4148 def: Pat<(v4i32 (PPCSExtVElems v16i8:$A)),
4149 (v4i32 (VEXTSB2W $A))>;
4150 def: Pat<(v4i32 (PPCSExtVElems v8i16:$A)),
4151 (v4i32 (VEXTSH2W $A))>;
4155 // Put this P9Altivec related definition here since it's possible to be
4156 // selected to VSX instruction xvnegsp, avoid possible undef.
4157 let Predicates = [HasP9Altivec] in {
4159 def : Pat<(v4i32 (PPCvabsd v4i32:$A, v4i32:$B, (i32 0))),
4160 (v4i32 (VABSDUW $A, $B))>;
4162 def : Pat<(v8i16 (PPCvabsd v8i16:$A, v8i16:$B, (i32 0))),
4163 (v8i16 (VABSDUH $A, $B))>;
4165 def : Pat<(v16i8 (PPCvabsd v16i8:$A, v16i8:$B, (i32 0))),
4166 (v16i8 (VABSDUB $A, $B))>;
4168 // As PPCVABSD description, the last operand indicates whether do the
4170 def : Pat<(v4i32 (PPCvabsd v4i32:$A, v4i32:$B, (i32 1))),
4171 (v4i32 (VABSDUW (XVNEGSP $A), (XVNEGSP $B)))>;