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 // *********************************** NOTE ***********************************
29 // ** When adding new anonymous patterns to this file, please add them to **
30 // ** the section titled Anonymous Patterns. Chances are that the existing **
31 // ** predicate blocks already contain a combination of features that you **
32 // ** are after. There is a list of blocks at the top of the section. If **
33 // ** you definitely need a new combination of predicates, please add that **
34 // ** combination to the list. **
35 // ** File Structure: **
36 // ** - Custom PPCISD node definitions **
37 // ** - Predicate definitions: predicates to specify the subtargets for **
38 // ** which an instruction or pattern can be emitted. **
39 // ** - Instruction formats: classes instantiated by the instructions. **
40 // ** These generally correspond to instruction formats in section 1.6 of **
41 // ** the ISA document. **
42 // ** - Instruction definitions: the actual definitions of the instructions **
43 // ** often including input patterns that they match. **
44 // ** - Helper DAG definitions: We define a number of dag objects to use as **
45 // ** input or output patterns for consciseness of the code. **
46 // ** - Anonymous patterns: input patterns that an instruction matches can **
47 // ** often not be specified as part of the instruction definition, so an **
48 // ** anonymous pattern must be specified mapping an input pattern to an **
49 // ** output pattern. These are generally guarded by subtarget predicates. **
50 // ** - Instruction aliases: used to define extended mnemonics for assembly **
51 // ** printing (for example: xxswapd for xxpermdi with 0x2 as the imm). **
52 // ****************************************************************************
54 def PPCRegVSRCAsmOperand : AsmOperandClass {
55 let Name = "RegVSRC"; let PredicateMethod = "isVSRegNumber";
57 def vsrc : RegisterOperand<VSRC> {
58 let ParserMatchClass = PPCRegVSRCAsmOperand;
61 def PPCRegVSFRCAsmOperand : AsmOperandClass {
62 let Name = "RegVSFRC"; let PredicateMethod = "isVSRegNumber";
64 def vsfrc : RegisterOperand<VSFRC> {
65 let ParserMatchClass = PPCRegVSFRCAsmOperand;
68 def PPCRegVSSRCAsmOperand : AsmOperandClass {
69 let Name = "RegVSSRC"; let PredicateMethod = "isVSRegNumber";
71 def vssrc : RegisterOperand<VSSRC> {
72 let ParserMatchClass = PPCRegVSSRCAsmOperand;
75 def PPCRegSPILLTOVSRRCAsmOperand : AsmOperandClass {
76 let Name = "RegSPILLTOVSRRC"; let PredicateMethod = "isVSRegNumber";
79 def spilltovsrrc : RegisterOperand<SPILLTOVSRRC> {
80 let ParserMatchClass = PPCRegSPILLTOVSRRCAsmOperand;
83 def SDT_PPCldvsxlh : SDTypeProfile<1, 1, [
84 SDTCisVT<0, v4f32>, SDTCisPtrTy<1>
87 def SDT_PPCfpexth : SDTypeProfile<1, 2, [
88 SDTCisVT<0, v2f64>, SDTCisVT<1, v4f32>, SDTCisPtrTy<2>
91 def SDT_PPCldsplat : SDTypeProfile<1, 1, [
92 SDTCisVec<0>, SDTCisPtrTy<1>
95 // Little-endian-specific nodes.
96 def SDT_PPClxvd2x : SDTypeProfile<1, 1, [
97 SDTCisVT<0, v2f64>, SDTCisPtrTy<1>
99 def SDT_PPCstxvd2x : SDTypeProfile<0, 2, [
100 SDTCisVT<0, v2f64>, SDTCisPtrTy<1>
102 def SDT_PPCxxswapd : SDTypeProfile<1, 1, [
105 def SDTVecConv : SDTypeProfile<1, 2, [
106 SDTCisVec<0>, SDTCisVec<1>, SDTCisPtrTy<2>
108 def SDTVabsd : SDTypeProfile<1, 3, [
109 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVT<3, i32>
111 def SDT_PPCld_vec_be : SDTypeProfile<1, 1, [
112 SDTCisVec<0>, SDTCisPtrTy<1>
114 def SDT_PPCst_vec_be : SDTypeProfile<0, 2, [
115 SDTCisVec<0>, SDTCisPtrTy<1>
118 //--------------------------- Custom PPC nodes -------------------------------//
119 def PPClxvd2x : SDNode<"PPCISD::LXVD2X", SDT_PPClxvd2x,
120 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
121 def PPCstxvd2x : SDNode<"PPCISD::STXVD2X", SDT_PPCstxvd2x,
122 [SDNPHasChain, SDNPMayStore]>;
123 def PPCld_vec_be : SDNode<"PPCISD::LOAD_VEC_BE", SDT_PPCld_vec_be,
124 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
125 def PPCst_vec_be : SDNode<"PPCISD::STORE_VEC_BE", SDT_PPCst_vec_be,
126 [SDNPHasChain, SDNPMayStore]>;
127 def PPCxxswapd : SDNode<"PPCISD::XXSWAPD", SDT_PPCxxswapd, [SDNPHasChain]>;
128 def PPCmfvsr : SDNode<"PPCISD::MFVSR", SDTUnaryOp, []>;
129 def PPCmtvsra : SDNode<"PPCISD::MTVSRA", SDTUnaryOp, []>;
130 def PPCmtvsrz : SDNode<"PPCISD::MTVSRZ", SDTUnaryOp, []>;
131 def PPCsvec2fp : SDNode<"PPCISD::SINT_VEC_TO_FP", SDTVecConv, []>;
132 def PPCuvec2fp: SDNode<"PPCISD::UINT_VEC_TO_FP", SDTVecConv, []>;
133 def PPCswapNoChain : SDNode<"PPCISD::SWAP_NO_CHAIN", SDT_PPCxxswapd>;
134 def PPCvabsd : SDNode<"PPCISD::VABSD", SDTVabsd, []>;
136 def PPCfpexth : SDNode<"PPCISD::FP_EXTEND_HALF", SDT_PPCfpexth, []>;
137 def PPCldvsxlh : SDNode<"PPCISD::LD_VSX_LH", SDT_PPCldvsxlh,
138 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
139 def PPCldsplat : SDNode<"PPCISD::LD_SPLAT", SDT_PPCldsplat,
140 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
141 def PPCSToV : SDNode<"PPCISD::SCALAR_TO_VECTOR_PERMUTED",
142 SDTypeProfile<1, 1, []>, []>;
144 //-------------------------- Predicate definitions ---------------------------//
145 def HasVSX : Predicate<"Subtarget->hasVSX()">;
146 def IsLittleEndian : Predicate<"Subtarget->isLittleEndian()">;
147 def IsBigEndian : Predicate<"!Subtarget->isLittleEndian()">;
148 def IsPPC64 : Predicate<"Subtarget->isPPC64()">;
149 def HasOnlySwappingMemOps : Predicate<"!Subtarget->hasP9Vector()">;
150 def HasP8Vector : Predicate<"Subtarget->hasP8Vector()">;
151 def HasDirectMove : Predicate<"Subtarget->hasDirectMove()">;
152 def NoP9Vector : Predicate<"!Subtarget->hasP9Vector()">;
153 def HasP9Vector : Predicate<"Subtarget->hasP9Vector()">;
154 def NoP9Altivec : Predicate<"!Subtarget->hasP9Altivec()">;
155 def NoP10Vector: Predicate<"!Subtarget->hasP10Vector()">;
157 //--------------------- VSX-specific instruction formats ---------------------//
158 // By default, all VSX instructions are to be selected over their Altivec
159 // counter parts and they do not have unmodeled sideeffects.
160 let AddedComplexity = 400, hasSideEffects = 0 in {
161 multiclass XX3Form_Rcr<bits<6> opcode, bits<7> xo, string asmbase,
162 string asmstr, InstrItinClass itin, Intrinsic Int,
163 ValueType OutTy, ValueType InTy> {
164 let BaseName = asmbase in {
165 def NAME : XX3Form_Rc<opcode, xo, (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
166 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
167 [(set OutTy:$XT, (Int InTy:$XA, InTy:$XB))]>;
169 def _rec : XX3Form_Rc<opcode, xo, (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
170 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
172 (InTy (PPCvcmp_rec InTy:$XA, InTy:$XB, xo)))]>,
177 // Instruction form with a single input register for instructions such as
178 // XXPERMDI. The reason for defining this is that specifying multiple chained
179 // operands (such as loads) to an instruction will perform both chained
180 // operations rather than coalescing them into a single register - even though
181 // the source memory location is the same. This simply forces the instruction
182 // to use the same register for both inputs.
183 // For example, an output DAG such as this:
184 // (XXPERMDI (LXSIBZX xoaddr:$src), (LXSIBZX xoaddr:$src ), 0))
185 // would result in two load instructions emitted and used as separate inputs
186 // to the XXPERMDI instruction.
187 class XX3Form_2s<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, string asmstr,
188 InstrItinClass itin, list<dag> pattern>
189 : XX3Form_2<opcode, xo, OOL, IOL, asmstr, itin, pattern> {
193 let Predicates = [HasVSX, HasP9Vector] in {
194 class X_VT5_XO5_VB5<bits<6> opcode, bits<5> xo2, bits<10> xo, string opc,
196 : X_RD5_XO5_RS5<opcode, xo2, xo, (outs vrrc:$vT), (ins vrrc:$vB),
197 !strconcat(opc, " $vT, $vB"), IIC_VecFP, pattern>;
199 // [PO VRT XO VRB XO RO], Round to Odd version of [PO VRT XO VRB XO /]
200 class X_VT5_XO5_VB5_Ro<bits<6> opcode, bits<5> xo2, bits<10> xo, string opc,
202 : X_VT5_XO5_VB5<opcode, xo2, xo, opc, pattern>, isRecordForm;
204 // [PO VRT XO VRB XO /], but the VRB is only used the left 64 bits (or less),
205 // So we use different operand class for VRB
206 class X_VT5_XO5_VB5_TyVB<bits<6> opcode, bits<5> xo2, bits<10> xo, string opc,
207 RegisterOperand vbtype, list<dag> pattern>
208 : X_RD5_XO5_RS5<opcode, xo2, xo, (outs vrrc:$vT), (ins vbtype:$vB),
209 !strconcat(opc, " $vT, $vB"), IIC_VecFP, pattern>;
211 // [PO VRT XO VRB XO /]
212 class X_VT5_XO5_VB5_VSFR<bits<6> opcode, bits<5> xo2, bits<10> xo, string opc,
214 : X_RD5_XO5_RS5<opcode, xo2, xo, (outs vfrc:$vT), (ins vrrc:$vB),
215 !strconcat(opc, " $vT, $vB"), IIC_VecFP, pattern>;
217 // [PO VRT XO VRB XO RO], Round to Odd version of [PO VRT XO VRB XO /]
218 class X_VT5_XO5_VB5_VSFR_Ro<bits<6> opcode, bits<5> xo2, bits<10> xo, string opc,
220 : X_VT5_XO5_VB5_VSFR<opcode, xo2, xo, opc, pattern>, isRecordForm;
222 // [PO T XO B XO BX /]
223 class XX2_RT5_XO5_XB6<bits<6> opcode, bits<5> xo2, bits<9> xo, string opc,
225 : XX2_RD5_XO5_RS6<opcode, xo2, xo, (outs g8rc:$rT), (ins vsfrc:$XB),
226 !strconcat(opc, " $rT, $XB"), IIC_VecFP, pattern>;
228 // [PO T XO B XO BX TX]
229 class XX2_XT6_XO5_XB6<bits<6> opcode, bits<5> xo2, bits<9> xo, string opc,
230 RegisterOperand vtype, list<dag> pattern>
231 : XX2_RD6_XO5_RS6<opcode, xo2, xo, (outs vtype:$XT), (ins vtype:$XB),
232 !strconcat(opc, " $XT, $XB"), IIC_VecFP, pattern>;
234 // [PO T A B XO AX BX TX], src and dest register use different operand class
235 class XX3_XT5_XA5_XB5<bits<6> opcode, bits<8> xo, string opc,
236 RegisterOperand xty, RegisterOperand aty, RegisterOperand bty,
237 InstrItinClass itin, list<dag> pattern>
238 : XX3Form<opcode, xo, (outs xty:$XT), (ins aty:$XA, bty:$XB),
239 !strconcat(opc, " $XT, $XA, $XB"), itin, pattern>;
241 // [PO VRT VRA VRB XO /]
242 class X_VT5_VA5_VB5<bits<6> opcode, bits<10> xo, string opc,
244 : XForm_1<opcode, xo, (outs vrrc:$vT), (ins vrrc:$vA, vrrc:$vB),
245 !strconcat(opc, " $vT, $vA, $vB"), IIC_VecFP, pattern>;
247 // [PO VRT VRA VRB XO RO], Round to Odd version of [PO VRT VRA VRB XO /]
248 class X_VT5_VA5_VB5_Ro<bits<6> opcode, bits<10> xo, string opc,
250 : X_VT5_VA5_VB5<opcode, xo, opc, pattern>, isRecordForm;
252 // [PO VRT VRA VRB XO /]
253 class X_VT5_VA5_VB5_FMA<bits<6> opcode, bits<10> xo, string opc,
255 : XForm_1<opcode, xo, (outs vrrc:$vT), (ins vrrc:$vTi, vrrc:$vA, vrrc:$vB),
256 !strconcat(opc, " $vT, $vA, $vB"), IIC_VecFP, pattern>,
257 RegConstraint<"$vTi = $vT">, NoEncode<"$vTi">;
259 // [PO VRT VRA VRB XO RO], Round to Odd version of [PO VRT VRA VRB XO /]
260 class X_VT5_VA5_VB5_FMA_Ro<bits<6> opcode, bits<10> xo, string opc,
262 : X_VT5_VA5_VB5_FMA<opcode, xo, opc, pattern>, isRecordForm;
264 class Z23_VT5_R1_VB5_RMC2_EX1<bits<6> opcode, bits<8> xo, bit ex, string opc,
266 : Z23Form_8<opcode, xo,
267 (outs vrrc:$vT), (ins u1imm:$r, vrrc:$vB, u2imm:$rmc),
268 !strconcat(opc, " $r, $vT, $vB, $rmc"), IIC_VecFP, pattern> {
272 // [PO BF // VRA VRB XO /]
273 class X_BF3_VA5_VB5<bits<6> opcode, bits<10> xo, string opc,
275 : XForm_17<opcode, xo, (outs crrc:$crD), (ins vrrc:$VA, vrrc:$VB),
276 !strconcat(opc, " $crD, $VA, $VB"), IIC_FPCompare> {
277 let Pattern = pattern;
280 // [PO T RA RB XO TX] almost equal to [PO S RA RB XO SX], but has different
281 // "out" and "in" dag
282 class X_XT6_RA5_RB5<bits<6> opcode, bits<10> xo, string opc,
283 RegisterOperand vtype, list<dag> pattern>
284 : XX1Form_memOp<opcode, xo, (outs vtype:$XT), (ins memrr:$src),
285 !strconcat(opc, " $XT, $src"), IIC_LdStLFD, pattern>;
287 // [PO S RA RB XO SX]
288 class X_XS6_RA5_RB5<bits<6> opcode, bits<10> xo, string opc,
289 RegisterOperand vtype, list<dag> pattern>
290 : XX1Form_memOp<opcode, xo, (outs), (ins vtype:$XT, memrr:$dst),
291 !strconcat(opc, " $XT, $dst"), IIC_LdStSTFD, pattern>;
292 } // Predicates = HasP9Vector
293 } // AddedComplexity = 400, hasSideEffects = 0
295 multiclass ScalToVecWPermute<ValueType Ty, dag In, dag NonPermOut, dag PermOut> {
296 def : Pat<(Ty (scalar_to_vector In)), (Ty NonPermOut)>;
297 def : Pat<(Ty (PPCSToV In)), (Ty PermOut)>;
300 //-------------------------- Instruction definitions -------------------------//
301 // VSX instructions require the VSX feature, they are to be selected over
302 // equivalent Altivec patterns (as they address a larger register set) and
303 // they do not have unmodeled side effects.
304 let Predicates = [HasVSX], AddedComplexity = 400 in {
305 let hasSideEffects = 0 in {
307 // Load indexed instructions
308 let mayLoad = 1, mayStore = 0 in {
310 def LXSDX : XX1Form_memOp<31, 588,
311 (outs vsfrc:$XT), (ins memrr:$src),
312 "lxsdx $XT, $src", IIC_LdStLFD,
315 // Pseudo instruction XFLOADf64 will be expanded to LXSDX or LFDX later
317 def XFLOADf64 : PseudoXFormMemOp<(outs vsfrc:$XT), (ins memrr:$src),
319 [(set f64:$XT, (load XForm:$src))]>;
321 let Predicates = [HasVSX, HasOnlySwappingMemOps] in
322 def LXVD2X : XX1Form_memOp<31, 844,
323 (outs vsrc:$XT), (ins memrr:$src),
324 "lxvd2x $XT, $src", IIC_LdStLFD,
327 def LXVDSX : XX1Form_memOp<31, 332,
328 (outs vsrc:$XT), (ins memrr:$src),
329 "lxvdsx $XT, $src", IIC_LdStLFD, []>;
331 let Predicates = [HasVSX, HasOnlySwappingMemOps] in
332 def LXVW4X : XX1Form_memOp<31, 780,
333 (outs vsrc:$XT), (ins memrr:$src),
334 "lxvw4x $XT, $src", IIC_LdStLFD,
338 // Store indexed instructions
339 let mayStore = 1, mayLoad = 0 in {
341 def STXSDX : XX1Form_memOp<31, 716,
342 (outs), (ins vsfrc:$XT, memrr:$dst),
343 "stxsdx $XT, $dst", IIC_LdStSTFD,
346 // Pseudo instruction XFSTOREf64 will be expanded to STXSDX or STFDX later
348 def XFSTOREf64 : PseudoXFormMemOp<(outs), (ins vsfrc:$XT, memrr:$dst),
350 [(store f64:$XT, XForm:$dst)]>;
352 let Predicates = [HasVSX, HasOnlySwappingMemOps] in {
353 // The behaviour of this instruction is endianness-specific so we provide no
354 // pattern to match it without considering endianness.
355 def STXVD2X : XX1Form_memOp<31, 972,
356 (outs), (ins vsrc:$XT, memrr:$dst),
357 "stxvd2x $XT, $dst", IIC_LdStSTFD,
360 def STXVW4X : XX1Form_memOp<31, 908,
361 (outs), (ins vsrc:$XT, memrr:$dst),
362 "stxvw4x $XT, $dst", IIC_LdStSTFD,
367 let mayRaiseFPException = 1 in {
369 // Add/Mul Instructions
370 let isCommutable = 1 in {
371 def XSADDDP : XX3Form<60, 32,
372 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
373 "xsadddp $XT, $XA, $XB", IIC_VecFP,
374 [(set f64:$XT, (any_fadd f64:$XA, f64:$XB))]>;
375 def XSMULDP : XX3Form<60, 48,
376 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
377 "xsmuldp $XT, $XA, $XB", IIC_VecFP,
378 [(set f64:$XT, (any_fmul f64:$XA, f64:$XB))]>;
380 def XVADDDP : XX3Form<60, 96,
381 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
382 "xvadddp $XT, $XA, $XB", IIC_VecFP,
383 [(set v2f64:$XT, (any_fadd v2f64:$XA, v2f64:$XB))]>;
385 def XVADDSP : XX3Form<60, 64,
386 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
387 "xvaddsp $XT, $XA, $XB", IIC_VecFP,
388 [(set v4f32:$XT, (any_fadd v4f32:$XA, v4f32:$XB))]>;
390 def XVMULDP : XX3Form<60, 112,
391 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
392 "xvmuldp $XT, $XA, $XB", IIC_VecFP,
393 [(set v2f64:$XT, (any_fmul v2f64:$XA, v2f64:$XB))]>;
395 def XVMULSP : XX3Form<60, 80,
396 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
397 "xvmulsp $XT, $XA, $XB", IIC_VecFP,
398 [(set v4f32:$XT, (any_fmul v4f32:$XA, v4f32:$XB))]>;
401 // Subtract Instructions
402 def XSSUBDP : XX3Form<60, 40,
403 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
404 "xssubdp $XT, $XA, $XB", IIC_VecFP,
405 [(set f64:$XT, (any_fsub f64:$XA, f64:$XB))]>;
407 def XVSUBDP : XX3Form<60, 104,
408 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
409 "xvsubdp $XT, $XA, $XB", IIC_VecFP,
410 [(set v2f64:$XT, (any_fsub v2f64:$XA, v2f64:$XB))]>;
411 def XVSUBSP : XX3Form<60, 72,
412 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
413 "xvsubsp $XT, $XA, $XB", IIC_VecFP,
414 [(set v4f32:$XT, (any_fsub v4f32:$XA, v4f32:$XB))]>;
417 let BaseName = "XSMADDADP" in {
418 let isCommutable = 1 in
419 def XSMADDADP : XX3Form<60, 33,
420 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
421 "xsmaddadp $XT, $XA, $XB", IIC_VecFP,
422 [(set f64:$XT, (any_fma f64:$XA, f64:$XB, f64:$XTi))]>,
423 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
425 let IsVSXFMAAlt = 1 in
426 def XSMADDMDP : XX3Form<60, 41,
427 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
428 "xsmaddmdp $XT, $XA, $XB", IIC_VecFP, []>,
429 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
433 let BaseName = "XSMSUBADP" in {
434 let isCommutable = 1 in
435 def XSMSUBADP : XX3Form<60, 49,
436 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
437 "xsmsubadp $XT, $XA, $XB", IIC_VecFP,
438 [(set f64:$XT, (any_fma f64:$XA, f64:$XB, (fneg f64:$XTi)))]>,
439 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
441 let IsVSXFMAAlt = 1 in
442 def XSMSUBMDP : XX3Form<60, 57,
443 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
444 "xsmsubmdp $XT, $XA, $XB", IIC_VecFP, []>,
445 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
449 let BaseName = "XSNMADDADP" in {
450 let isCommutable = 1 in
451 def XSNMADDADP : XX3Form<60, 161,
452 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
453 "xsnmaddadp $XT, $XA, $XB", IIC_VecFP,
454 [(set f64:$XT, (fneg (any_fma f64:$XA, f64:$XB, f64:$XTi)))]>,
455 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
457 let IsVSXFMAAlt = 1 in
458 def XSNMADDMDP : XX3Form<60, 169,
459 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
460 "xsnmaddmdp $XT, $XA, $XB", IIC_VecFP, []>,
461 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
465 let BaseName = "XSNMSUBADP" in {
466 let isCommutable = 1 in
467 def XSNMSUBADP : XX3Form<60, 177,
468 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
469 "xsnmsubadp $XT, $XA, $XB", IIC_VecFP,
470 [(set f64:$XT, (fneg (any_fma f64:$XA, f64:$XB, (fneg f64:$XTi))))]>,
471 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
473 let IsVSXFMAAlt = 1 in
474 def XSNMSUBMDP : XX3Form<60, 185,
475 (outs vsfrc:$XT), (ins vsfrc:$XTi, vsfrc:$XA, vsfrc:$XB),
476 "xsnmsubmdp $XT, $XA, $XB", IIC_VecFP, []>,
477 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
481 let BaseName = "XVMADDADP" in {
482 let isCommutable = 1 in
483 def XVMADDADP : XX3Form<60, 97,
484 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
485 "xvmaddadp $XT, $XA, $XB", IIC_VecFP,
486 [(set v2f64:$XT, (any_fma v2f64:$XA, v2f64:$XB, v2f64:$XTi))]>,
487 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
489 let IsVSXFMAAlt = 1 in
490 def XVMADDMDP : XX3Form<60, 105,
491 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
492 "xvmaddmdp $XT, $XA, $XB", IIC_VecFP, []>,
493 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
497 let BaseName = "XVMADDASP" in {
498 let isCommutable = 1 in
499 def XVMADDASP : XX3Form<60, 65,
500 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
501 "xvmaddasp $XT, $XA, $XB", IIC_VecFP,
502 [(set v4f32:$XT, (any_fma v4f32:$XA, v4f32:$XB, v4f32:$XTi))]>,
503 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
505 let IsVSXFMAAlt = 1 in
506 def XVMADDMSP : XX3Form<60, 73,
507 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
508 "xvmaddmsp $XT, $XA, $XB", IIC_VecFP, []>,
509 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
513 let BaseName = "XVMSUBADP" in {
514 let isCommutable = 1 in
515 def XVMSUBADP : XX3Form<60, 113,
516 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
517 "xvmsubadp $XT, $XA, $XB", IIC_VecFP,
518 [(set v2f64:$XT, (any_fma v2f64:$XA, v2f64:$XB, (fneg v2f64:$XTi)))]>,
519 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
521 let IsVSXFMAAlt = 1 in
522 def XVMSUBMDP : XX3Form<60, 121,
523 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
524 "xvmsubmdp $XT, $XA, $XB", IIC_VecFP, []>,
525 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
529 let BaseName = "XVMSUBASP" in {
530 let isCommutable = 1 in
531 def XVMSUBASP : XX3Form<60, 81,
532 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
533 "xvmsubasp $XT, $XA, $XB", IIC_VecFP,
534 [(set v4f32:$XT, (any_fma v4f32:$XA, v4f32:$XB, (fneg v4f32:$XTi)))]>,
535 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
537 let IsVSXFMAAlt = 1 in
538 def XVMSUBMSP : XX3Form<60, 89,
539 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
540 "xvmsubmsp $XT, $XA, $XB", IIC_VecFP, []>,
541 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
545 let BaseName = "XVNMADDADP" in {
546 let isCommutable = 1 in
547 def XVNMADDADP : XX3Form<60, 225,
548 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
549 "xvnmaddadp $XT, $XA, $XB", IIC_VecFP,
550 [(set v2f64:$XT, (fneg (any_fma v2f64:$XA, v2f64:$XB, v2f64:$XTi)))]>,
551 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
553 let IsVSXFMAAlt = 1 in
554 def XVNMADDMDP : XX3Form<60, 233,
555 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
556 "xvnmaddmdp $XT, $XA, $XB", IIC_VecFP, []>,
557 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
561 let BaseName = "XVNMADDASP" in {
562 let isCommutable = 1 in
563 def XVNMADDASP : XX3Form<60, 193,
564 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
565 "xvnmaddasp $XT, $XA, $XB", IIC_VecFP,
566 [(set v4f32:$XT, (fneg (fma v4f32:$XA, v4f32:$XB, v4f32:$XTi)))]>,
567 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
569 let IsVSXFMAAlt = 1 in
570 def XVNMADDMSP : XX3Form<60, 201,
571 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
572 "xvnmaddmsp $XT, $XA, $XB", IIC_VecFP, []>,
573 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
577 let BaseName = "XVNMSUBADP" in {
578 let isCommutable = 1 in
579 def XVNMSUBADP : XX3Form<60, 241,
580 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
581 "xvnmsubadp $XT, $XA, $XB", IIC_VecFP,
582 [(set v2f64:$XT, (fneg (any_fma v2f64:$XA, v2f64:$XB, (fneg v2f64:$XTi))))]>,
583 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
585 let IsVSXFMAAlt = 1 in
586 def XVNMSUBMDP : XX3Form<60, 249,
587 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
588 "xvnmsubmdp $XT, $XA, $XB", IIC_VecFP, []>,
589 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
593 let BaseName = "XVNMSUBASP" in {
594 let isCommutable = 1 in
595 def XVNMSUBASP : XX3Form<60, 209,
596 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
597 "xvnmsubasp $XT, $XA, $XB", IIC_VecFP,
598 [(set v4f32:$XT, (fneg (any_fma v4f32:$XA, v4f32:$XB, (fneg v4f32:$XTi))))]>,
599 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
601 let IsVSXFMAAlt = 1 in
602 def XVNMSUBMSP : XX3Form<60, 217,
603 (outs vsrc:$XT), (ins vsrc:$XTi, vsrc:$XA, vsrc:$XB),
604 "xvnmsubmsp $XT, $XA, $XB", IIC_VecFP, []>,
605 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
609 // Division Instructions
610 def XSDIVDP : XX3Form<60, 56,
611 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
612 "xsdivdp $XT, $XA, $XB", IIC_FPDivD,
613 [(set f64:$XT, (any_fdiv f64:$XA, f64:$XB))]>;
614 def XSSQRTDP : XX2Form<60, 75,
615 (outs vsfrc:$XT), (ins vsfrc:$XB),
616 "xssqrtdp $XT, $XB", IIC_FPSqrtD,
617 [(set f64:$XT, (any_fsqrt f64:$XB))]>;
619 def XSREDP : XX2Form<60, 90,
620 (outs vsfrc:$XT), (ins vsfrc:$XB),
621 "xsredp $XT, $XB", IIC_VecFP,
622 [(set f64:$XT, (PPCfre f64:$XB))]>;
623 def XSRSQRTEDP : XX2Form<60, 74,
624 (outs vsfrc:$XT), (ins vsfrc:$XB),
625 "xsrsqrtedp $XT, $XB", IIC_VecFP,
626 [(set f64:$XT, (PPCfrsqrte f64:$XB))]>;
628 let mayRaiseFPException = 0 in {
629 def XSTDIVDP : XX3Form_1<60, 61,
630 (outs crrc:$crD), (ins vsfrc:$XA, vsfrc:$XB),
631 "xstdivdp $crD, $XA, $XB", IIC_FPCompare, []>;
632 def XSTSQRTDP : XX2Form_1<60, 106,
633 (outs crrc:$crD), (ins vsfrc:$XB),
634 "xstsqrtdp $crD, $XB", IIC_FPCompare,
635 [(set i32:$crD, (PPCftsqrt f64:$XB))]>;
636 def XVTDIVDP : XX3Form_1<60, 125,
637 (outs crrc:$crD), (ins vsrc:$XA, vsrc:$XB),
638 "xvtdivdp $crD, $XA, $XB", IIC_FPCompare, []>;
639 def XVTDIVSP : XX3Form_1<60, 93,
640 (outs crrc:$crD), (ins vsrc:$XA, vsrc:$XB),
641 "xvtdivsp $crD, $XA, $XB", IIC_FPCompare, []>;
643 def XVTSQRTDP : XX2Form_1<60, 234,
644 (outs crrc:$crD), (ins vsrc:$XB),
645 "xvtsqrtdp $crD, $XB", IIC_FPCompare,
646 [(set i32:$crD, (PPCftsqrt v2f64:$XB))]>;
647 def XVTSQRTSP : XX2Form_1<60, 170,
648 (outs crrc:$crD), (ins vsrc:$XB),
649 "xvtsqrtsp $crD, $XB", IIC_FPCompare,
650 [(set i32:$crD, (PPCftsqrt v4f32:$XB))]>;
653 def XVDIVDP : XX3Form<60, 120,
654 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
655 "xvdivdp $XT, $XA, $XB", IIC_FPDivD,
656 [(set v2f64:$XT, (any_fdiv v2f64:$XA, v2f64:$XB))]>;
657 def XVDIVSP : XX3Form<60, 88,
658 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
659 "xvdivsp $XT, $XA, $XB", IIC_FPDivS,
660 [(set v4f32:$XT, (any_fdiv v4f32:$XA, v4f32:$XB))]>;
662 def XVSQRTDP : XX2Form<60, 203,
663 (outs vsrc:$XT), (ins vsrc:$XB),
664 "xvsqrtdp $XT, $XB", IIC_FPSqrtD,
665 [(set v2f64:$XT, (any_fsqrt v2f64:$XB))]>;
666 def XVSQRTSP : XX2Form<60, 139,
667 (outs vsrc:$XT), (ins vsrc:$XB),
668 "xvsqrtsp $XT, $XB", IIC_FPSqrtS,
669 [(set v4f32:$XT, (any_fsqrt v4f32:$XB))]>;
671 def XVREDP : XX2Form<60, 218,
672 (outs vsrc:$XT), (ins vsrc:$XB),
673 "xvredp $XT, $XB", IIC_VecFP,
674 [(set v2f64:$XT, (PPCfre v2f64:$XB))]>;
675 def XVRESP : XX2Form<60, 154,
676 (outs vsrc:$XT), (ins vsrc:$XB),
677 "xvresp $XT, $XB", IIC_VecFP,
678 [(set v4f32:$XT, (PPCfre v4f32:$XB))]>;
680 def XVRSQRTEDP : XX2Form<60, 202,
681 (outs vsrc:$XT), (ins vsrc:$XB),
682 "xvrsqrtedp $XT, $XB", IIC_VecFP,
683 [(set v2f64:$XT, (PPCfrsqrte v2f64:$XB))]>;
684 def XVRSQRTESP : XX2Form<60, 138,
685 (outs vsrc:$XT), (ins vsrc:$XB),
686 "xvrsqrtesp $XT, $XB", IIC_VecFP,
687 [(set v4f32:$XT, (PPCfrsqrte v4f32:$XB))]>;
689 // Compare Instructions
690 def XSCMPODP : XX3Form_1<60, 43,
691 (outs crrc:$crD), (ins vsfrc:$XA, vsfrc:$XB),
692 "xscmpodp $crD, $XA, $XB", IIC_FPCompare, []>;
693 def XSCMPUDP : XX3Form_1<60, 35,
694 (outs crrc:$crD), (ins vsfrc:$XA, vsfrc:$XB),
695 "xscmpudp $crD, $XA, $XB", IIC_FPCompare, []>;
697 defm XVCMPEQDP : XX3Form_Rcr<60, 99,
698 "xvcmpeqdp", "$XT, $XA, $XB", IIC_VecFPCompare,
699 int_ppc_vsx_xvcmpeqdp, v2i64, v2f64>;
700 defm XVCMPEQSP : XX3Form_Rcr<60, 67,
701 "xvcmpeqsp", "$XT, $XA, $XB", IIC_VecFPCompare,
702 int_ppc_vsx_xvcmpeqsp, v4i32, v4f32>;
703 defm XVCMPGEDP : XX3Form_Rcr<60, 115,
704 "xvcmpgedp", "$XT, $XA, $XB", IIC_VecFPCompare,
705 int_ppc_vsx_xvcmpgedp, v2i64, v2f64>;
706 defm XVCMPGESP : XX3Form_Rcr<60, 83,
707 "xvcmpgesp", "$XT, $XA, $XB", IIC_VecFPCompare,
708 int_ppc_vsx_xvcmpgesp, v4i32, v4f32>;
709 defm XVCMPGTDP : XX3Form_Rcr<60, 107,
710 "xvcmpgtdp", "$XT, $XA, $XB", IIC_VecFPCompare,
711 int_ppc_vsx_xvcmpgtdp, v2i64, v2f64>;
712 defm XVCMPGTSP : XX3Form_Rcr<60, 75,
713 "xvcmpgtsp", "$XT, $XA, $XB", IIC_VecFPCompare,
714 int_ppc_vsx_xvcmpgtsp, v4i32, v4f32>;
717 let mayRaiseFPException = 0 in {
718 def XSABSDP : XX2Form<60, 345,
719 (outs vsfrc:$XT), (ins vsfrc:$XB),
720 "xsabsdp $XT, $XB", IIC_VecFP,
721 [(set f64:$XT, (fabs f64:$XB))]>;
722 def XSNABSDP : XX2Form<60, 361,
723 (outs vsfrc:$XT), (ins vsfrc:$XB),
724 "xsnabsdp $XT, $XB", IIC_VecFP,
725 [(set f64:$XT, (fneg (fabs f64:$XB)))]>;
726 def XSNEGDP : XX2Form<60, 377,
727 (outs vsfrc:$XT), (ins vsfrc:$XB),
728 "xsnegdp $XT, $XB", IIC_VecFP,
729 [(set f64:$XT, (fneg f64:$XB))]>;
730 def XSCPSGNDP : XX3Form<60, 176,
731 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
732 "xscpsgndp $XT, $XA, $XB", IIC_VecFP,
733 [(set f64:$XT, (fcopysign f64:$XB, f64:$XA))]>;
735 def XVABSDP : XX2Form<60, 473,
736 (outs vsrc:$XT), (ins vsrc:$XB),
737 "xvabsdp $XT, $XB", IIC_VecFP,
738 [(set v2f64:$XT, (fabs v2f64:$XB))]>;
740 def XVABSSP : XX2Form<60, 409,
741 (outs vsrc:$XT), (ins vsrc:$XB),
742 "xvabssp $XT, $XB", IIC_VecFP,
743 [(set v4f32:$XT, (fabs v4f32:$XB))]>;
745 def XVCPSGNDP : XX3Form<60, 240,
746 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
747 "xvcpsgndp $XT, $XA, $XB", IIC_VecFP,
748 [(set v2f64:$XT, (fcopysign v2f64:$XB, v2f64:$XA))]>;
749 def XVCPSGNSP : XX3Form<60, 208,
750 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
751 "xvcpsgnsp $XT, $XA, $XB", IIC_VecFP,
752 [(set v4f32:$XT, (fcopysign v4f32:$XB, v4f32:$XA))]>;
754 def XVNABSDP : XX2Form<60, 489,
755 (outs vsrc:$XT), (ins vsrc:$XB),
756 "xvnabsdp $XT, $XB", IIC_VecFP,
757 [(set v2f64:$XT, (fneg (fabs v2f64:$XB)))]>;
758 def XVNABSSP : XX2Form<60, 425,
759 (outs vsrc:$XT), (ins vsrc:$XB),
760 "xvnabssp $XT, $XB", IIC_VecFP,
761 [(set v4f32:$XT, (fneg (fabs v4f32:$XB)))]>;
763 def XVNEGDP : XX2Form<60, 505,
764 (outs vsrc:$XT), (ins vsrc:$XB),
765 "xvnegdp $XT, $XB", IIC_VecFP,
766 [(set v2f64:$XT, (fneg v2f64:$XB))]>;
767 def XVNEGSP : XX2Form<60, 441,
768 (outs vsrc:$XT), (ins vsrc:$XB),
769 "xvnegsp $XT, $XB", IIC_VecFP,
770 [(set v4f32:$XT, (fneg v4f32:$XB))]>;
773 // Conversion Instructions
774 def XSCVDPSP : XX2Form<60, 265,
775 (outs vsfrc:$XT), (ins vsfrc:$XB),
776 "xscvdpsp $XT, $XB", IIC_VecFP, []>;
777 def XSCVDPSXDS : XX2Form<60, 344,
778 (outs vsfrc:$XT), (ins vsfrc:$XB),
779 "xscvdpsxds $XT, $XB", IIC_VecFP,
780 [(set f64:$XT, (PPCany_fctidz f64:$XB))]>;
781 let isCodeGenOnly = 1 in
782 def XSCVDPSXDSs : XX2Form<60, 344,
783 (outs vssrc:$XT), (ins vssrc:$XB),
784 "xscvdpsxds $XT, $XB", IIC_VecFP,
785 [(set f32:$XT, (PPCany_fctidz f32:$XB))]>;
786 def XSCVDPSXWS : XX2Form<60, 88,
787 (outs vsfrc:$XT), (ins vsfrc:$XB),
788 "xscvdpsxws $XT, $XB", IIC_VecFP,
789 [(set f64:$XT, (PPCany_fctiwz f64:$XB))]>;
790 let isCodeGenOnly = 1 in
791 def XSCVDPSXWSs : XX2Form<60, 88,
792 (outs vssrc:$XT), (ins vssrc:$XB),
793 "xscvdpsxws $XT, $XB", IIC_VecFP,
794 [(set f32:$XT, (PPCany_fctiwz f32:$XB))]>;
795 def XSCVDPUXDS : XX2Form<60, 328,
796 (outs vsfrc:$XT), (ins vsfrc:$XB),
797 "xscvdpuxds $XT, $XB", IIC_VecFP,
798 [(set f64:$XT, (PPCany_fctiduz f64:$XB))]>;
799 let isCodeGenOnly = 1 in
800 def XSCVDPUXDSs : XX2Form<60, 328,
801 (outs vssrc:$XT), (ins vssrc:$XB),
802 "xscvdpuxds $XT, $XB", IIC_VecFP,
803 [(set f32:$XT, (PPCany_fctiduz f32:$XB))]>;
804 def XSCVDPUXWS : XX2Form<60, 72,
805 (outs vsfrc:$XT), (ins vsfrc:$XB),
806 "xscvdpuxws $XT, $XB", IIC_VecFP,
807 [(set f64:$XT, (PPCany_fctiwuz f64:$XB))]>;
808 let isCodeGenOnly = 1 in
809 def XSCVDPUXWSs : XX2Form<60, 72,
810 (outs vssrc:$XT), (ins vssrc:$XB),
811 "xscvdpuxws $XT, $XB", IIC_VecFP,
812 [(set f32:$XT, (PPCany_fctiwuz f32:$XB))]>;
813 def XSCVSPDP : XX2Form<60, 329,
814 (outs vsfrc:$XT), (ins vsfrc:$XB),
815 "xscvspdp $XT, $XB", IIC_VecFP, []>;
816 def XSCVSXDDP : XX2Form<60, 376,
817 (outs vsfrc:$XT), (ins vsfrc:$XB),
818 "xscvsxddp $XT, $XB", IIC_VecFP,
819 [(set f64:$XT, (PPCany_fcfid f64:$XB))]>;
820 def XSCVUXDDP : XX2Form<60, 360,
821 (outs vsfrc:$XT), (ins vsfrc:$XB),
822 "xscvuxddp $XT, $XB", IIC_VecFP,
823 [(set f64:$XT, (PPCany_fcfidu f64:$XB))]>;
825 def XVCVDPSP : XX2Form<60, 393,
826 (outs vsrc:$XT), (ins vsrc:$XB),
827 "xvcvdpsp $XT, $XB", IIC_VecFP,
828 [(set v4f32:$XT, (int_ppc_vsx_xvcvdpsp v2f64:$XB))]>;
829 def XVCVDPSXDS : XX2Form<60, 472,
830 (outs vsrc:$XT), (ins vsrc:$XB),
831 "xvcvdpsxds $XT, $XB", IIC_VecFP,
832 [(set v2i64:$XT, (any_fp_to_sint v2f64:$XB))]>;
833 def XVCVDPSXWS : XX2Form<60, 216,
834 (outs vsrc:$XT), (ins vsrc:$XB),
835 "xvcvdpsxws $XT, $XB", IIC_VecFP,
836 [(set v4i32:$XT, (int_ppc_vsx_xvcvdpsxws v2f64:$XB))]>;
837 def XVCVDPUXDS : XX2Form<60, 456,
838 (outs vsrc:$XT), (ins vsrc:$XB),
839 "xvcvdpuxds $XT, $XB", IIC_VecFP,
840 [(set v2i64:$XT, (any_fp_to_uint v2f64:$XB))]>;
841 def XVCVDPUXWS : XX2Form<60, 200,
842 (outs vsrc:$XT), (ins vsrc:$XB),
843 "xvcvdpuxws $XT, $XB", IIC_VecFP,
844 [(set v4i32:$XT, (int_ppc_vsx_xvcvdpuxws v2f64:$XB))]>;
846 def XVCVSPDP : XX2Form<60, 457,
847 (outs vsrc:$XT), (ins vsrc:$XB),
848 "xvcvspdp $XT, $XB", IIC_VecFP,
849 [(set v2f64:$XT, (int_ppc_vsx_xvcvspdp v4f32:$XB))]>;
850 def XVCVSPSXDS : XX2Form<60, 408,
851 (outs vsrc:$XT), (ins vsrc:$XB),
852 "xvcvspsxds $XT, $XB", IIC_VecFP,
853 [(set v2i64:$XT, (int_ppc_vsx_xvcvspsxds v4f32:$XB))]>;
854 def XVCVSPSXWS : XX2Form<60, 152,
855 (outs vsrc:$XT), (ins vsrc:$XB),
856 "xvcvspsxws $XT, $XB", IIC_VecFP,
857 [(set v4i32:$XT, (any_fp_to_sint v4f32:$XB))]>;
858 def XVCVSPUXDS : XX2Form<60, 392,
859 (outs vsrc:$XT), (ins vsrc:$XB),
860 "xvcvspuxds $XT, $XB", IIC_VecFP,
861 [(set v2i64:$XT, (int_ppc_vsx_xvcvspuxds v4f32:$XB))]>;
862 def XVCVSPUXWS : XX2Form<60, 136,
863 (outs vsrc:$XT), (ins vsrc:$XB),
864 "xvcvspuxws $XT, $XB", IIC_VecFP,
865 [(set v4i32:$XT, (any_fp_to_uint v4f32:$XB))]>;
866 def XVCVSXDDP : XX2Form<60, 504,
867 (outs vsrc:$XT), (ins vsrc:$XB),
868 "xvcvsxddp $XT, $XB", IIC_VecFP,
869 [(set v2f64:$XT, (any_sint_to_fp v2i64:$XB))]>;
870 def XVCVSXDSP : XX2Form<60, 440,
871 (outs vsrc:$XT), (ins vsrc:$XB),
872 "xvcvsxdsp $XT, $XB", IIC_VecFP,
873 [(set v4f32:$XT, (int_ppc_vsx_xvcvsxdsp v2i64:$XB))]>;
874 def XVCVSXWSP : XX2Form<60, 184,
875 (outs vsrc:$XT), (ins vsrc:$XB),
876 "xvcvsxwsp $XT, $XB", IIC_VecFP,
877 [(set v4f32:$XT, (any_sint_to_fp v4i32:$XB))]>;
878 def XVCVUXDDP : XX2Form<60, 488,
879 (outs vsrc:$XT), (ins vsrc:$XB),
880 "xvcvuxddp $XT, $XB", IIC_VecFP,
881 [(set v2f64:$XT, (any_uint_to_fp v2i64:$XB))]>;
882 def XVCVUXDSP : XX2Form<60, 424,
883 (outs vsrc:$XT), (ins vsrc:$XB),
884 "xvcvuxdsp $XT, $XB", IIC_VecFP,
885 [(set v4f32:$XT, (int_ppc_vsx_xvcvuxdsp v2i64:$XB))]>;
886 def XVCVUXWSP : XX2Form<60, 168,
887 (outs vsrc:$XT), (ins vsrc:$XB),
888 "xvcvuxwsp $XT, $XB", IIC_VecFP,
889 [(set v4f32:$XT, (any_uint_to_fp v4i32:$XB))]>;
891 let mayRaiseFPException = 0 in {
892 def XVCVSXWDP : XX2Form<60, 248,
893 (outs vsrc:$XT), (ins vsrc:$XB),
894 "xvcvsxwdp $XT, $XB", IIC_VecFP,
895 [(set v2f64:$XT, (int_ppc_vsx_xvcvsxwdp v4i32:$XB))]>;
896 def XVCVUXWDP : XX2Form<60, 232,
897 (outs vsrc:$XT), (ins vsrc:$XB),
898 "xvcvuxwdp $XT, $XB", IIC_VecFP,
899 [(set v2f64:$XT, (int_ppc_vsx_xvcvuxwdp v4i32:$XB))]>;
902 // Rounding Instructions respecting current rounding mode
903 def XSRDPIC : XX2Form<60, 107,
904 (outs vsfrc:$XT), (ins vsfrc:$XB),
905 "xsrdpic $XT, $XB", IIC_VecFP,
906 [(set f64:$XT, (fnearbyint f64:$XB))]>;
907 def XVRDPIC : XX2Form<60, 235,
908 (outs vsrc:$XT), (ins vsrc:$XB),
909 "xvrdpic $XT, $XB", IIC_VecFP,
910 [(set v2f64:$XT, (fnearbyint v2f64:$XB))]>;
911 def XVRSPIC : XX2Form<60, 171,
912 (outs vsrc:$XT), (ins vsrc:$XB),
913 "xvrspic $XT, $XB", IIC_VecFP,
914 [(set v4f32:$XT, (fnearbyint v4f32:$XB))]>;
915 // Max/Min Instructions
916 let isCommutable = 1 in {
917 def XSMAXDP : XX3Form<60, 160,
918 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
919 "xsmaxdp $XT, $XA, $XB", IIC_VecFP,
921 (int_ppc_vsx_xsmaxdp vsfrc:$XA, vsfrc:$XB))]>;
922 def XSMINDP : XX3Form<60, 168,
923 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
924 "xsmindp $XT, $XA, $XB", IIC_VecFP,
926 (int_ppc_vsx_xsmindp vsfrc:$XA, vsfrc:$XB))]>;
928 def XVMAXDP : XX3Form<60, 224,
929 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
930 "xvmaxdp $XT, $XA, $XB", IIC_VecFP,
932 (int_ppc_vsx_xvmaxdp vsrc:$XA, vsrc:$XB))]>;
933 def XVMINDP : XX3Form<60, 232,
934 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
935 "xvmindp $XT, $XA, $XB", IIC_VecFP,
937 (int_ppc_vsx_xvmindp vsrc:$XA, vsrc:$XB))]>;
939 def XVMAXSP : XX3Form<60, 192,
940 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
941 "xvmaxsp $XT, $XA, $XB", IIC_VecFP,
943 (int_ppc_vsx_xvmaxsp vsrc:$XA, vsrc:$XB))]>;
944 def XVMINSP : XX3Form<60, 200,
945 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
946 "xvminsp $XT, $XA, $XB", IIC_VecFP,
948 (int_ppc_vsx_xvminsp vsrc:$XA, vsrc:$XB))]>;
952 // Rounding Instructions with static direction.
953 def XSRDPI : XX2Form<60, 73,
954 (outs vsfrc:$XT), (ins vsfrc:$XB),
955 "xsrdpi $XT, $XB", IIC_VecFP,
956 [(set f64:$XT, (any_fround f64:$XB))]>;
957 def XSRDPIM : XX2Form<60, 121,
958 (outs vsfrc:$XT), (ins vsfrc:$XB),
959 "xsrdpim $XT, $XB", IIC_VecFP,
960 [(set f64:$XT, (any_ffloor f64:$XB))]>;
961 def XSRDPIP : XX2Form<60, 105,
962 (outs vsfrc:$XT), (ins vsfrc:$XB),
963 "xsrdpip $XT, $XB", IIC_VecFP,
964 [(set f64:$XT, (any_fceil f64:$XB))]>;
965 def XSRDPIZ : XX2Form<60, 89,
966 (outs vsfrc:$XT), (ins vsfrc:$XB),
967 "xsrdpiz $XT, $XB", IIC_VecFP,
968 [(set f64:$XT, (any_ftrunc f64:$XB))]>;
970 def XVRDPI : XX2Form<60, 201,
971 (outs vsrc:$XT), (ins vsrc:$XB),
972 "xvrdpi $XT, $XB", IIC_VecFP,
973 [(set v2f64:$XT, (any_fround v2f64:$XB))]>;
974 def XVRDPIM : XX2Form<60, 249,
975 (outs vsrc:$XT), (ins vsrc:$XB),
976 "xvrdpim $XT, $XB", IIC_VecFP,
977 [(set v2f64:$XT, (any_ffloor v2f64:$XB))]>;
978 def XVRDPIP : XX2Form<60, 233,
979 (outs vsrc:$XT), (ins vsrc:$XB),
980 "xvrdpip $XT, $XB", IIC_VecFP,
981 [(set v2f64:$XT, (any_fceil v2f64:$XB))]>;
982 def XVRDPIZ : XX2Form<60, 217,
983 (outs vsrc:$XT), (ins vsrc:$XB),
984 "xvrdpiz $XT, $XB", IIC_VecFP,
985 [(set v2f64:$XT, (any_ftrunc v2f64:$XB))]>;
987 def XVRSPI : XX2Form<60, 137,
988 (outs vsrc:$XT), (ins vsrc:$XB),
989 "xvrspi $XT, $XB", IIC_VecFP,
990 [(set v4f32:$XT, (any_fround v4f32:$XB))]>;
991 def XVRSPIM : XX2Form<60, 185,
992 (outs vsrc:$XT), (ins vsrc:$XB),
993 "xvrspim $XT, $XB", IIC_VecFP,
994 [(set v4f32:$XT, (any_ffloor v4f32:$XB))]>;
995 def XVRSPIP : XX2Form<60, 169,
996 (outs vsrc:$XT), (ins vsrc:$XB),
997 "xvrspip $XT, $XB", IIC_VecFP,
998 [(set v4f32:$XT, (any_fceil v4f32:$XB))]>;
999 def XVRSPIZ : XX2Form<60, 153,
1000 (outs vsrc:$XT), (ins vsrc:$XB),
1001 "xvrspiz $XT, $XB", IIC_VecFP,
1002 [(set v4f32:$XT, (any_ftrunc v4f32:$XB))]>;
1003 } // mayRaiseFPException
1005 // Logical Instructions
1006 let isCommutable = 1 in
1007 def XXLAND : XX3Form<60, 130,
1008 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1009 "xxland $XT, $XA, $XB", IIC_VecGeneral,
1010 [(set v4i32:$XT, (and v4i32:$XA, v4i32:$XB))]>;
1011 def XXLANDC : XX3Form<60, 138,
1012 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1013 "xxlandc $XT, $XA, $XB", IIC_VecGeneral,
1014 [(set v4i32:$XT, (and v4i32:$XA,
1015 (vnot v4i32:$XB)))]>;
1016 let isCommutable = 1 in {
1017 def XXLNOR : XX3Form<60, 162,
1018 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1019 "xxlnor $XT, $XA, $XB", IIC_VecGeneral,
1020 [(set v4i32:$XT, (vnot (or v4i32:$XA,
1022 def XXLOR : XX3Form<60, 146,
1023 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1024 "xxlor $XT, $XA, $XB", IIC_VecGeneral,
1025 [(set v4i32:$XT, (or v4i32:$XA, v4i32:$XB))]>;
1026 let isCodeGenOnly = 1 in
1027 def XXLORf: XX3Form<60, 146,
1028 (outs vsfrc:$XT), (ins vsfrc:$XA, vsfrc:$XB),
1029 "xxlor $XT, $XA, $XB", IIC_VecGeneral, []>;
1030 def XXLXOR : XX3Form<60, 154,
1031 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1032 "xxlxor $XT, $XA, $XB", IIC_VecGeneral,
1033 [(set v4i32:$XT, (xor v4i32:$XA, v4i32:$XB))]>;
1036 let isCodeGenOnly = 1, isMoveImm = 1, isAsCheapAsAMove = 1,
1037 isReMaterializable = 1 in {
1038 def XXLXORz : XX3Form_SameOp<60, 154, (outs vsrc:$XT), (ins),
1039 "xxlxor $XT, $XT, $XT", IIC_VecGeneral,
1040 [(set v4i32:$XT, (v4i32 immAllZerosV))]>;
1041 def XXLXORdpz : XX3Form_SameOp<60, 154,
1042 (outs vsfrc:$XT), (ins),
1043 "xxlxor $XT, $XT, $XT", IIC_VecGeneral,
1044 [(set f64:$XT, (fpimm0))]>;
1045 def XXLXORspz : XX3Form_SameOp<60, 154,
1046 (outs vssrc:$XT), (ins),
1047 "xxlxor $XT, $XT, $XT", IIC_VecGeneral,
1048 [(set f32:$XT, (fpimm0))]>;
1051 // Permutation Instructions
1052 def XXMRGHW : XX3Form<60, 18,
1053 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1054 "xxmrghw $XT, $XA, $XB", IIC_VecPerm, []>;
1055 def XXMRGLW : XX3Form<60, 50,
1056 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1057 "xxmrglw $XT, $XA, $XB", IIC_VecPerm, []>;
1059 def XXPERMDI : XX3Form_2<60, 10,
1060 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB, u2imm:$DM),
1061 "xxpermdi $XT, $XA, $XB, $DM", IIC_VecPerm,
1062 [(set v2i64:$XT, (PPCxxpermdi v2i64:$XA, v2i64:$XB,
1063 imm32SExt16:$DM))]>;
1064 let isCodeGenOnly = 1 in
1065 def XXPERMDIs : XX3Form_2s<60, 10, (outs vsrc:$XT), (ins vsfrc:$XA, u2imm:$DM),
1066 "xxpermdi $XT, $XA, $XA, $DM", IIC_VecPerm, []>;
1067 def XXSEL : XX4Form<60, 3,
1068 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB, vsrc:$XC),
1069 "xxsel $XT, $XA, $XB, $XC", IIC_VecPerm, []>;
1071 def XXSLDWI : XX3Form_2<60, 2,
1072 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB, u2imm:$SHW),
1073 "xxsldwi $XT, $XA, $XB, $SHW", IIC_VecPerm,
1074 [(set v4i32:$XT, (PPCvecshl v4i32:$XA, v4i32:$XB,
1075 imm32SExt16:$SHW))]>;
1077 let isCodeGenOnly = 1 in
1078 def XXSLDWIs : XX3Form_2s<60, 2,
1079 (outs vsrc:$XT), (ins vsfrc:$XA, u2imm:$SHW),
1080 "xxsldwi $XT, $XA, $XA, $SHW", IIC_VecPerm, []>;
1082 def XXSPLTW : XX2Form_2<60, 164,
1083 (outs vsrc:$XT), (ins vsrc:$XB, u2imm:$UIM),
1084 "xxspltw $XT, $XB, $UIM", IIC_VecPerm,
1086 (PPCxxsplt v4i32:$XB, imm32SExt16:$UIM))]>;
1087 let isCodeGenOnly = 1 in
1088 def XXSPLTWs : XX2Form_2<60, 164,
1089 (outs vsrc:$XT), (ins vsfrc:$XB, u2imm:$UIM),
1090 "xxspltw $XT, $XB, $UIM", IIC_VecPerm, []>;
1092 // The following VSX instructions were introduced in Power ISA 2.07
1093 let Predicates = [HasVSX, HasP8Vector] in {
1094 let isCommutable = 1 in {
1095 def XXLEQV : XX3Form<60, 186,
1096 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1097 "xxleqv $XT, $XA, $XB", IIC_VecGeneral,
1098 [(set v4i32:$XT, (vnot (xor v4i32:$XA, v4i32:$XB)))]>;
1099 def XXLNAND : XX3Form<60, 178,
1100 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1101 "xxlnand $XT, $XA, $XB", IIC_VecGeneral,
1102 [(set v4i32:$XT, (vnot (and v4i32:$XA, v4i32:$XB)))]>;
1105 let isCodeGenOnly = 1, isMoveImm = 1, isAsCheapAsAMove = 1,
1106 isReMaterializable = 1 in {
1107 def XXLEQVOnes : XX3Form_SameOp<60, 186, (outs vsrc:$XT), (ins),
1108 "xxleqv $XT, $XT, $XT", IIC_VecGeneral,
1109 [(set v4i32:$XT, (bitconvert (v16i8 immAllOnesV)))]>;
1112 def XXLORC : XX3Form<60, 170,
1113 (outs vsrc:$XT), (ins vsrc:$XA, vsrc:$XB),
1114 "xxlorc $XT, $XA, $XB", IIC_VecGeneral,
1115 [(set v4i32:$XT, (or v4i32:$XA, (vnot v4i32:$XB)))]>;
1117 // VSX scalar loads introduced in ISA 2.07
1118 let mayLoad = 1, mayStore = 0 in {
1120 def LXSSPX : XX1Form_memOp<31, 524, (outs vssrc:$XT), (ins memrr:$src),
1121 "lxsspx $XT, $src", IIC_LdStLFD, []>;
1122 def LXSIWAX : XX1Form_memOp<31, 76, (outs vsfrc:$XT), (ins memrr:$src),
1123 "lxsiwax $XT, $src", IIC_LdStLFD, []>;
1124 def LXSIWZX : XX1Form_memOp<31, 12, (outs vsfrc:$XT), (ins memrr:$src),
1125 "lxsiwzx $XT, $src", IIC_LdStLFD, []>;
1127 // Pseudo instruction XFLOADf32 will be expanded to LXSSPX or LFSX later
1129 def XFLOADf32 : PseudoXFormMemOp<(outs vssrc:$XT), (ins memrr:$src),
1131 [(set f32:$XT, (load XForm:$src))]>;
1132 // Pseudo instruction LIWAX will be expanded to LXSIWAX or LFIWAX later
1133 def LIWAX : PseudoXFormMemOp<(outs vsfrc:$XT), (ins memrr:$src),
1135 [(set f64:$XT, (PPClfiwax ForceXForm:$src))]>;
1136 // Pseudo instruction LIWZX will be expanded to LXSIWZX or LFIWZX later
1137 def LIWZX : PseudoXFormMemOp<(outs vsfrc:$XT), (ins memrr:$src),
1139 [(set f64:$XT, (PPClfiwzx ForceXForm:$src))]>;
1142 // VSX scalar stores introduced in ISA 2.07
1143 let mayStore = 1, mayLoad = 0 in {
1145 def STXSSPX : XX1Form_memOp<31, 652, (outs), (ins vssrc:$XT, memrr:$dst),
1146 "stxsspx $XT, $dst", IIC_LdStSTFD, []>;
1147 def STXSIWX : XX1Form_memOp<31, 140, (outs), (ins vsfrc:$XT, memrr:$dst),
1148 "stxsiwx $XT, $dst", IIC_LdStSTFD, []>;
1150 // Pseudo instruction XFSTOREf32 will be expanded to STXSSPX or STFSX later
1152 def XFSTOREf32 : PseudoXFormMemOp<(outs), (ins vssrc:$XT, memrr:$dst),
1154 [(store f32:$XT, XForm:$dst)]>;
1155 // Pseudo instruction STIWX will be expanded to STXSIWX or STFIWX later
1156 def STIWX : PseudoXFormMemOp<(outs), (ins vsfrc:$XT, memrr:$dst),
1158 [(PPCstfiwx f64:$XT, ForceXForm:$dst)]>;
1161 // VSX Elementary Scalar FP arithmetic (SP)
1162 let mayRaiseFPException = 1 in {
1163 let isCommutable = 1 in {
1164 def XSADDSP : XX3Form<60, 0,
1165 (outs vssrc:$XT), (ins vssrc:$XA, vssrc:$XB),
1166 "xsaddsp $XT, $XA, $XB", IIC_VecFP,
1167 [(set f32:$XT, (any_fadd f32:$XA, f32:$XB))]>;
1168 def XSMULSP : XX3Form<60, 16,
1169 (outs vssrc:$XT), (ins vssrc:$XA, vssrc:$XB),
1170 "xsmulsp $XT, $XA, $XB", IIC_VecFP,
1171 [(set f32:$XT, (any_fmul f32:$XA, f32:$XB))]>;
1174 def XSSUBSP : XX3Form<60, 8,
1175 (outs vssrc:$XT), (ins vssrc:$XA, vssrc:$XB),
1176 "xssubsp $XT, $XA, $XB", IIC_VecFP,
1177 [(set f32:$XT, (any_fsub f32:$XA, f32:$XB))]>;
1178 def XSDIVSP : XX3Form<60, 24,
1179 (outs vssrc:$XT), (ins vssrc:$XA, vssrc:$XB),
1180 "xsdivsp $XT, $XA, $XB", IIC_FPDivS,
1181 [(set f32:$XT, (any_fdiv f32:$XA, f32:$XB))]>;
1183 def XSRESP : XX2Form<60, 26,
1184 (outs vssrc:$XT), (ins vssrc:$XB),
1185 "xsresp $XT, $XB", IIC_VecFP,
1186 [(set f32:$XT, (PPCfre f32:$XB))]>;
1187 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1188 let hasSideEffects = 1 in
1189 def XSRSP : XX2Form<60, 281,
1190 (outs vssrc:$XT), (ins vsfrc:$XB),
1191 "xsrsp $XT, $XB", IIC_VecFP,
1192 [(set f32:$XT, (any_fpround f64:$XB))]>;
1193 def XSSQRTSP : XX2Form<60, 11,
1194 (outs vssrc:$XT), (ins vssrc:$XB),
1195 "xssqrtsp $XT, $XB", IIC_FPSqrtS,
1196 [(set f32:$XT, (any_fsqrt f32:$XB))]>;
1197 def XSRSQRTESP : XX2Form<60, 10,
1198 (outs vssrc:$XT), (ins vssrc:$XB),
1199 "xsrsqrtesp $XT, $XB", IIC_VecFP,
1200 [(set f32:$XT, (PPCfrsqrte f32:$XB))]>;
1203 let BaseName = "XSMADDASP" in {
1204 let isCommutable = 1 in
1205 def XSMADDASP : XX3Form<60, 1,
1207 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1208 "xsmaddasp $XT, $XA, $XB", IIC_VecFP,
1209 [(set f32:$XT, (any_fma f32:$XA, f32:$XB, f32:$XTi))]>,
1210 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1212 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1213 let IsVSXFMAAlt = 1, hasSideEffects = 1 in
1214 def XSMADDMSP : XX3Form<60, 9,
1216 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1217 "xsmaddmsp $XT, $XA, $XB", IIC_VecFP, []>,
1218 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1222 let BaseName = "XSMSUBASP" in {
1223 let isCommutable = 1 in
1224 def XSMSUBASP : XX3Form<60, 17,
1226 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1227 "xsmsubasp $XT, $XA, $XB", IIC_VecFP,
1228 [(set f32:$XT, (any_fma f32:$XA, f32:$XB,
1229 (fneg f32:$XTi)))]>,
1230 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1232 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1233 let IsVSXFMAAlt = 1, hasSideEffects = 1 in
1234 def XSMSUBMSP : XX3Form<60, 25,
1236 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1237 "xsmsubmsp $XT, $XA, $XB", IIC_VecFP, []>,
1238 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1242 let BaseName = "XSNMADDASP" in {
1243 let isCommutable = 1 in
1244 def XSNMADDASP : XX3Form<60, 129,
1246 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1247 "xsnmaddasp $XT, $XA, $XB", IIC_VecFP,
1248 [(set f32:$XT, (fneg (any_fma f32:$XA, f32:$XB,
1250 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1252 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1253 let IsVSXFMAAlt = 1, hasSideEffects = 1 in
1254 def XSNMADDMSP : XX3Form<60, 137,
1256 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1257 "xsnmaddmsp $XT, $XA, $XB", IIC_VecFP, []>,
1258 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1262 let BaseName = "XSNMSUBASP" in {
1263 let isCommutable = 1 in
1264 def XSNMSUBASP : XX3Form<60, 145,
1266 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1267 "xsnmsubasp $XT, $XA, $XB", IIC_VecFP,
1268 [(set f32:$XT, (fneg (any_fma f32:$XA, f32:$XB,
1269 (fneg f32:$XTi))))]>,
1270 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1272 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1273 let IsVSXFMAAlt = 1, hasSideEffects = 1 in
1274 def XSNMSUBMSP : XX3Form<60, 153,
1276 (ins vssrc:$XTi, vssrc:$XA, vssrc:$XB),
1277 "xsnmsubmsp $XT, $XA, $XB", IIC_VecFP, []>,
1278 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">,
1282 // Single Precision Conversions (FP <-> INT)
1283 def XSCVSXDSP : XX2Form<60, 312,
1284 (outs vssrc:$XT), (ins vsfrc:$XB),
1285 "xscvsxdsp $XT, $XB", IIC_VecFP,
1286 [(set f32:$XT, (PPCany_fcfids f64:$XB))]>;
1287 def XSCVUXDSP : XX2Form<60, 296,
1288 (outs vssrc:$XT), (ins vsfrc:$XB),
1289 "xscvuxdsp $XT, $XB", IIC_VecFP,
1290 [(set f32:$XT, (PPCany_fcfidus f64:$XB))]>;
1291 } // mayRaiseFPException
1293 // Conversions between vector and scalar single precision
1294 def XSCVDPSPN : XX2Form<60, 267, (outs vsrc:$XT), (ins vssrc:$XB),
1295 "xscvdpspn $XT, $XB", IIC_VecFP, []>;
1296 def XSCVSPDPN : XX2Form<60, 331, (outs vssrc:$XT), (ins vsrc:$XB),
1297 "xscvspdpn $XT, $XB", IIC_VecFP, []>;
1299 let Predicates = [HasVSX, HasDirectMove] in {
1300 // VSX direct move instructions
1301 def MFVSRD : XX1_RS6_RD5_XO<31, 51, (outs g8rc:$rA), (ins vsfrc:$XT),
1302 "mfvsrd $rA, $XT", IIC_VecGeneral,
1303 [(set i64:$rA, (PPCmfvsr f64:$XT))]>,
1304 Requires<[In64BitMode]>;
1305 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1306 let isCodeGenOnly = 1, hasSideEffects = 1 in
1307 def MFVRD : XX1_RS6_RD5_XO<31, 51, (outs g8rc:$rA), (ins vsrc:$XT),
1308 "mfvsrd $rA, $XT", IIC_VecGeneral,
1310 Requires<[In64BitMode]>;
1311 def MFVSRWZ : XX1_RS6_RD5_XO<31, 115, (outs gprc:$rA), (ins vsfrc:$XT),
1312 "mfvsrwz $rA, $XT", IIC_VecGeneral,
1313 [(set i32:$rA, (PPCmfvsr f64:$XT))]>;
1314 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1315 let isCodeGenOnly = 1, hasSideEffects = 1 in
1316 def MFVRWZ : XX1_RS6_RD5_XO<31, 115, (outs gprc:$rA), (ins vsrc:$XT),
1317 "mfvsrwz $rA, $XT", IIC_VecGeneral,
1319 def MTVSRD : XX1_RS6_RD5_XO<31, 179, (outs vsfrc:$XT), (ins g8rc:$rA),
1320 "mtvsrd $XT, $rA", IIC_VecGeneral,
1321 [(set f64:$XT, (PPCmtvsra i64:$rA))]>,
1322 Requires<[In64BitMode]>;
1323 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1324 let isCodeGenOnly = 1, hasSideEffects = 1 in
1325 def MTVRD : XX1_RS6_RD5_XO<31, 179, (outs vsrc:$XT), (ins g8rc:$rA),
1326 "mtvsrd $XT, $rA", IIC_VecGeneral,
1328 Requires<[In64BitMode]>;
1329 def MTVSRWA : XX1_RS6_RD5_XO<31, 211, (outs vsfrc:$XT), (ins gprc:$rA),
1330 "mtvsrwa $XT, $rA", IIC_VecGeneral,
1331 [(set f64:$XT, (PPCmtvsra i32:$rA))]>;
1332 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1333 let isCodeGenOnly = 1, hasSideEffects = 1 in
1334 def MTVRWA : XX1_RS6_RD5_XO<31, 211, (outs vsrc:$XT), (ins gprc:$rA),
1335 "mtvsrwa $XT, $rA", IIC_VecGeneral,
1337 def MTVSRWZ : XX1_RS6_RD5_XO<31, 243, (outs vsfrc:$XT), (ins gprc:$rA),
1338 "mtvsrwz $XT, $rA", IIC_VecGeneral,
1339 [(set f64:$XT, (PPCmtvsrz i32:$rA))]>;
1340 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1341 let isCodeGenOnly = 1, hasSideEffects = 1 in
1342 def MTVRWZ : XX1_RS6_RD5_XO<31, 243, (outs vsrc:$XT), (ins gprc:$rA),
1343 "mtvsrwz $XT, $rA", IIC_VecGeneral,
1347 } // HasVSX, HasP8Vector
1349 let Predicates = [HasVSX, IsISA3_0, HasDirectMove] in {
1350 def MTVSRWS: XX1_RS6_RD5_XO<31, 403, (outs vsrc:$XT), (ins gprc:$rA),
1351 "mtvsrws $XT, $rA", IIC_VecGeneral, []>;
1353 def MTVSRDD: XX1Form<31, 435, (outs vsrc:$XT), (ins g8rc_nox0:$rA, g8rc:$rB),
1354 "mtvsrdd $XT, $rA, $rB", IIC_VecGeneral,
1355 []>, Requires<[In64BitMode]>;
1357 def MFVSRLD: XX1_RS6_RD5_XO<31, 307, (outs g8rc:$rA), (ins vsrc:$XT),
1358 "mfvsrld $rA, $XT", IIC_VecGeneral,
1359 []>, Requires<[In64BitMode]>;
1361 } // HasVSX, IsISA3_0, HasDirectMove
1363 let Predicates = [HasVSX, HasP9Vector] in {
1364 // Quad-Precision Scalar Move Instructions:
1366 def XSCPSGNQP : X_VT5_VA5_VB5<63, 100, "xscpsgnqp",
1368 (fcopysign f128:$vB, f128:$vA))]>;
1370 // Absolute/Negative-Absolute/Negate
1371 def XSABSQP : X_VT5_XO5_VB5<63, 0, 804, "xsabsqp",
1372 [(set f128:$vT, (fabs f128:$vB))]>;
1373 def XSNABSQP : X_VT5_XO5_VB5<63, 8, 804, "xsnabsqp",
1374 [(set f128:$vT, (fneg (fabs f128:$vB)))]>;
1375 def XSNEGQP : X_VT5_XO5_VB5<63, 16, 804, "xsnegqp",
1376 [(set f128:$vT, (fneg f128:$vB))]>;
1378 //===--------------------------------------------------------------------===//
1379 // Quad-Precision Scalar Floating-Point Arithmetic Instructions:
1381 // Add/Divide/Multiply/Subtract
1382 let mayRaiseFPException = 1 in {
1383 let isCommutable = 1 in {
1384 def XSADDQP : X_VT5_VA5_VB5 <63, 4, "xsaddqp",
1385 [(set f128:$vT, (any_fadd f128:$vA, f128:$vB))]>;
1386 def XSMULQP : X_VT5_VA5_VB5 <63, 36, "xsmulqp",
1387 [(set f128:$vT, (any_fmul f128:$vA, f128:$vB))]>;
1389 def XSSUBQP : X_VT5_VA5_VB5 <63, 516, "xssubqp" ,
1390 [(set f128:$vT, (any_fsub f128:$vA, f128:$vB))]>;
1391 def XSDIVQP : X_VT5_VA5_VB5 <63, 548, "xsdivqp",
1392 [(set f128:$vT, (any_fdiv f128:$vA, f128:$vB))]>;
1394 def XSSQRTQP : X_VT5_XO5_VB5 <63, 27, 804, "xssqrtqp",
1395 [(set f128:$vT, (any_fsqrt f128:$vB))]>;
1396 // (Negative) Multiply-{Add/Subtract}
1397 def XSMADDQP : X_VT5_VA5_VB5_FMA <63, 388, "xsmaddqp",
1399 (any_fma f128:$vA, f128:$vB, f128:$vTi))]>;
1400 def XSMSUBQP : X_VT5_VA5_VB5_FMA <63, 420, "xsmsubqp" ,
1402 (any_fma f128:$vA, f128:$vB,
1403 (fneg f128:$vTi)))]>;
1404 def XSNMADDQP : X_VT5_VA5_VB5_FMA <63, 452, "xsnmaddqp",
1406 (fneg (any_fma f128:$vA, f128:$vB,
1408 def XSNMSUBQP : X_VT5_VA5_VB5_FMA <63, 484, "xsnmsubqp",
1410 (fneg (any_fma f128:$vA, f128:$vB,
1411 (fneg f128:$vTi))))]>;
1413 let isCommutable = 1 in {
1414 def XSADDQPO : X_VT5_VA5_VB5_Ro<63, 4, "xsaddqpo",
1416 (int_ppc_addf128_round_to_odd
1417 f128:$vA, f128:$vB))]>;
1418 def XSMULQPO : X_VT5_VA5_VB5_Ro<63, 36, "xsmulqpo",
1420 (int_ppc_mulf128_round_to_odd
1421 f128:$vA, f128:$vB))]>;
1423 def XSSUBQPO : X_VT5_VA5_VB5_Ro<63, 516, "xssubqpo",
1425 (int_ppc_subf128_round_to_odd
1426 f128:$vA, f128:$vB))]>;
1427 def XSDIVQPO : X_VT5_VA5_VB5_Ro<63, 548, "xsdivqpo",
1429 (int_ppc_divf128_round_to_odd
1430 f128:$vA, f128:$vB))]>;
1431 def XSSQRTQPO : X_VT5_XO5_VB5_Ro<63, 27, 804, "xssqrtqpo",
1433 (int_ppc_sqrtf128_round_to_odd f128:$vB))]>;
1436 def XSMADDQPO : X_VT5_VA5_VB5_FMA_Ro<63, 388, "xsmaddqpo",
1438 (int_ppc_fmaf128_round_to_odd
1439 f128:$vA,f128:$vB,f128:$vTi))]>;
1441 def XSMSUBQPO : X_VT5_VA5_VB5_FMA_Ro<63, 420, "xsmsubqpo" ,
1443 (int_ppc_fmaf128_round_to_odd
1444 f128:$vA, f128:$vB, (fneg f128:$vTi)))]>;
1445 def XSNMADDQPO: X_VT5_VA5_VB5_FMA_Ro<63, 452, "xsnmaddqpo",
1447 (fneg (int_ppc_fmaf128_round_to_odd
1448 f128:$vA, f128:$vB, f128:$vTi)))]>;
1449 def XSNMSUBQPO: X_VT5_VA5_VB5_FMA_Ro<63, 484, "xsnmsubqpo",
1451 (fneg (int_ppc_fmaf128_round_to_odd
1452 f128:$vA, f128:$vB, (fneg f128:$vTi))))]>;
1453 } // mayRaiseFPException
1455 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1456 // QP Compare Ordered/Unordered
1457 let hasSideEffects = 1 in {
1458 // DP/QP Compare Exponents
1459 def XSCMPEXPDP : XX3Form_1<60, 59,
1460 (outs crrc:$crD), (ins vsfrc:$XA, vsfrc:$XB),
1461 "xscmpexpdp $crD, $XA, $XB", IIC_FPCompare, []>;
1462 def XSCMPEXPQP : X_BF3_VA5_VB5<63, 164, "xscmpexpqp", []>;
1464 let mayRaiseFPException = 1 in {
1465 def XSCMPOQP : X_BF3_VA5_VB5<63, 132, "xscmpoqp", []>;
1466 def XSCMPUQP : X_BF3_VA5_VB5<63, 644, "xscmpuqp", []>;
1468 // DP Compare ==, >=, >, !=
1469 // Use vsrc for XT, because the entire register of XT is set.
1470 // XT.dword[1] = 0x0000_0000_0000_0000
1471 def XSCMPEQDP : XX3_XT5_XA5_XB5<60, 3, "xscmpeqdp", vsrc, vsfrc, vsfrc,
1473 def XSCMPGEDP : XX3_XT5_XA5_XB5<60, 19, "xscmpgedp", vsrc, vsfrc, vsfrc,
1475 def XSCMPGTDP : XX3_XT5_XA5_XB5<60, 11, "xscmpgtdp", vsrc, vsfrc, vsfrc,
1480 //===--------------------------------------------------------------------===//
1481 // Quad-Precision Floating-Point Conversion Instructions:
1483 let mayRaiseFPException = 1 in {
1485 def XSCVDPQP : X_VT5_XO5_VB5_TyVB<63, 22, 836, "xscvdpqp", vfrc,
1486 [(set f128:$vT, (any_fpextend f64:$vB))]>;
1488 // Round & Convert QP -> DP (dword[1] is set to zero)
1489 def XSCVQPDP : X_VT5_XO5_VB5_VSFR<63, 20, 836, "xscvqpdp" , []>;
1490 def XSCVQPDPO : X_VT5_XO5_VB5_VSFR_Ro<63, 20, 836, "xscvqpdpo",
1492 (int_ppc_truncf128_round_to_odd
1496 // Truncate & Convert QP -> (Un)Signed (D)Word (dword[1] is set to zero)
1497 let mayRaiseFPException = 1 in {
1498 def XSCVQPSDZ : X_VT5_XO5_VB5<63, 25, 836, "xscvqpsdz", []>;
1499 def XSCVQPSWZ : X_VT5_XO5_VB5<63, 9, 836, "xscvqpswz", []>;
1500 def XSCVQPUDZ : X_VT5_XO5_VB5<63, 17, 836, "xscvqpudz", []>;
1501 def XSCVQPUWZ : X_VT5_XO5_VB5<63, 1, 836, "xscvqpuwz", []>;
1504 // Convert (Un)Signed DWord -> QP.
1505 def XSCVSDQP : X_VT5_XO5_VB5_TyVB<63, 10, 836, "xscvsdqp", vfrc, []>;
1506 def XSCVUDQP : X_VT5_XO5_VB5_TyVB<63, 2, 836, "xscvudqp", vfrc, []>;
1508 // (Round &) Convert DP <-> HP
1509 // Note! xscvdphp's src and dest register both use the left 64 bits, so we use
1510 // vsfrc for src and dest register. xscvhpdp's src only use the left 16 bits,
1511 // but we still use vsfrc for it.
1512 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1513 let hasSideEffects = 1, mayRaiseFPException = 1 in {
1514 def XSCVDPHP : XX2_XT6_XO5_XB6<60, 17, 347, "xscvdphp", vsfrc, []>;
1515 def XSCVHPDP : XX2_XT6_XO5_XB6<60, 16, 347, "xscvhpdp", vsfrc, []>;
1518 let mayRaiseFPException = 1 in {
1520 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1521 let hasSideEffects = 1 in
1522 def XVCVHPSP : XX2_XT6_XO5_XB6<60, 24, 475, "xvcvhpsp", vsrc, []>;
1523 def XVCVSPHP : XX2_XT6_XO5_XB6<60, 25, 475, "xvcvsphp", vsrc,
1525 (int_ppc_vsx_xvcvsphp v4f32:$XB))]>;
1527 // Round to Quad-Precision Integer [with Inexact]
1528 def XSRQPI : Z23_VT5_R1_VB5_RMC2_EX1<63, 5, 0, "xsrqpi" , []>;
1529 def XSRQPIX : Z23_VT5_R1_VB5_RMC2_EX1<63, 5, 1, "xsrqpix", []>;
1531 // Round Quad-Precision to Double-Extended Precision (fp80)
1532 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1533 let hasSideEffects = 1 in
1534 def XSRQPXP : Z23_VT5_R1_VB5_RMC2_EX1<63, 37, 0, "xsrqpxp", []>;
1537 //===--------------------------------------------------------------------===//
1538 // Insert/Extract Instructions
1540 // Insert Exponent DP/QP
1541 // XT NOTE: XT.dword[1] = 0xUUUU_UUUU_UUUU_UUUU
1542 def XSIEXPDP : XX1Form <60, 918, (outs vsrc:$XT), (ins g8rc:$rA, g8rc:$rB),
1543 "xsiexpdp $XT, $rA, $rB", IIC_VecFP, []>;
1544 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1545 let hasSideEffects = 1 in {
1546 // vB NOTE: only vB.dword[0] is used, that's why we don't use
1547 // X_VT5_VA5_VB5 form
1548 def XSIEXPQP : XForm_18<63, 868, (outs vrrc:$vT), (ins vrrc:$vA, vsfrc:$vB),
1549 "xsiexpqp $vT, $vA, $vB", IIC_VecFP, []>;
1552 // Extract Exponent/Significand DP/QP
1553 def XSXEXPDP : XX2_RT5_XO5_XB6<60, 0, 347, "xsxexpdp", []>;
1554 def XSXSIGDP : XX2_RT5_XO5_XB6<60, 1, 347, "xsxsigdp", []>;
1556 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1557 let hasSideEffects = 1 in {
1558 def XSXEXPQP : X_VT5_XO5_VB5 <63, 2, 804, "xsxexpqp", []>;
1559 def XSXSIGQP : X_VT5_XO5_VB5 <63, 18, 804, "xsxsigqp", []>;
1562 // Vector Insert Word
1563 // XB NOTE: Only XB.dword[1] is used, but we use vsrc on XB.
1565 XX2_RD6_UIM5_RS6<60, 181, (outs vsrc:$XT),
1566 (ins vsrc:$XTi, vsrc:$XB, u4imm:$UIM),
1567 "xxinsertw $XT, $XB, $UIM", IIC_VecFP,
1568 [(set v4i32:$XT, (PPCvecinsert v4i32:$XTi, v4i32:$XB,
1569 imm32SExt16:$UIM))]>,
1570 RegConstraint<"$XTi = $XT">, NoEncode<"$XTi">;
1572 // Vector Extract Unsigned Word
1573 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1574 let hasSideEffects = 1 in
1575 def XXEXTRACTUW : XX2_RD6_UIM5_RS6<60, 165,
1576 (outs vsfrc:$XT), (ins vsrc:$XB, u4imm:$UIMM),
1577 "xxextractuw $XT, $XB, $UIMM", IIC_VecFP, []>;
1579 // Vector Insert Exponent DP/SP
1580 def XVIEXPDP : XX3_XT5_XA5_XB5<60, 248, "xviexpdp", vsrc, vsrc, vsrc,
1581 IIC_VecFP, [(set v2f64: $XT,(int_ppc_vsx_xviexpdp v2i64:$XA, v2i64:$XB))]>;
1582 def XVIEXPSP : XX3_XT5_XA5_XB5<60, 216, "xviexpsp", vsrc, vsrc, vsrc,
1583 IIC_VecFP, [(set v4f32: $XT,(int_ppc_vsx_xviexpsp v4i32:$XA, v4i32:$XB))]>;
1585 // Vector Extract Exponent/Significand DP/SP
1586 def XVXEXPDP : XX2_XT6_XO5_XB6<60, 0, 475, "xvxexpdp", vsrc,
1588 (int_ppc_vsx_xvxexpdp v2f64:$XB))]>;
1589 def XVXEXPSP : XX2_XT6_XO5_XB6<60, 8, 475, "xvxexpsp", vsrc,
1591 (int_ppc_vsx_xvxexpsp v4f32:$XB))]>;
1592 def XVXSIGDP : XX2_XT6_XO5_XB6<60, 1, 475, "xvxsigdp", vsrc,
1594 (int_ppc_vsx_xvxsigdp v2f64:$XB))]>;
1595 def XVXSIGSP : XX2_XT6_XO5_XB6<60, 9, 475, "xvxsigsp", vsrc,
1597 (int_ppc_vsx_xvxsigsp v4f32:$XB))]>;
1599 // Test Data Class SP/DP/QP
1600 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1601 let hasSideEffects = 1 in {
1602 def XSTSTDCSP : XX2_BF3_DCMX7_RS6<60, 298,
1603 (outs crrc:$BF), (ins u7imm:$DCMX, vsfrc:$XB),
1604 "xststdcsp $BF, $XB, $DCMX", IIC_VecFP, []>;
1605 def XSTSTDCDP : XX2_BF3_DCMX7_RS6<60, 362,
1606 (outs crrc:$BF), (ins u7imm:$DCMX, vsfrc:$XB),
1607 "xststdcdp $BF, $XB, $DCMX", IIC_VecFP, []>;
1608 def XSTSTDCQP : X_BF3_DCMX7_RS5 <63, 708,
1609 (outs crrc:$BF), (ins u7imm:$DCMX, vrrc:$vB),
1610 "xststdcqp $BF, $vB, $DCMX", IIC_VecFP, []>;
1613 // Vector Test Data Class SP/DP
1614 def XVTSTDCSP : XX2_RD6_DCMX7_RS6<60, 13, 5,
1615 (outs vsrc:$XT), (ins u7imm:$DCMX, vsrc:$XB),
1616 "xvtstdcsp $XT, $XB, $DCMX", IIC_VecFP,
1618 (int_ppc_vsx_xvtstdcsp v4f32:$XB, timm:$DCMX))]>;
1619 def XVTSTDCDP : XX2_RD6_DCMX7_RS6<60, 15, 5,
1620 (outs vsrc:$XT), (ins u7imm:$DCMX, vsrc:$XB),
1621 "xvtstdcdp $XT, $XB, $DCMX", IIC_VecFP,
1623 (int_ppc_vsx_xvtstdcdp v2f64:$XB, timm:$DCMX))]>;
1625 // Maximum/Minimum Type-C/Type-J DP
1626 let mayRaiseFPException = 1 in {
1627 def XSMAXCDP : XX3_XT5_XA5_XB5<60, 128, "xsmaxcdp", vsfrc, vsfrc, vsfrc,
1629 [(set f64:$XT, (PPCxsmaxc f64:$XA, f64:$XB))]>;
1630 def XSMINCDP : XX3_XT5_XA5_XB5<60, 136, "xsmincdp", vsfrc, vsfrc, vsfrc,
1632 [(set f64:$XT, (PPCxsminc f64:$XA, f64:$XB))]>;
1634 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1635 let hasSideEffects = 1 in {
1636 def XSMAXJDP : XX3_XT5_XA5_XB5<60, 144, "xsmaxjdp", vsrc, vsfrc, vsfrc,
1638 def XSMINJDP : XX3_XT5_XA5_XB5<60, 152, "xsminjdp", vsrc, vsfrc, vsfrc,
1643 // Vector Byte-Reverse H/W/D/Q Word
1644 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1645 let hasSideEffects = 1 in
1646 def XXBRH : XX2_XT6_XO5_XB6<60, 7, 475, "xxbrh", vsrc, []>;
1647 def XXBRW : XX2_XT6_XO5_XB6<60, 15, 475, "xxbrw", vsrc,
1648 [(set v4i32:$XT, (bswap v4i32:$XB))]>;
1649 def XXBRD : XX2_XT6_XO5_XB6<60, 23, 475, "xxbrd", vsrc,
1650 [(set v2i64:$XT, (bswap v2i64:$XB))]>;
1651 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1652 let hasSideEffects = 1 in
1653 def XXBRQ : XX2_XT6_XO5_XB6<60, 31, 475, "xxbrq", vsrc, []>;
1656 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1657 let hasSideEffects = 1 in {
1658 def XXPERM : XX3_XT5_XA5_XB5<60, 26, "xxperm" , vsrc, vsrc, vsrc,
1660 def XXPERMR : XX3_XT5_XA5_XB5<60, 58, "xxpermr", vsrc, vsrc, vsrc,
1664 // Vector Splat Immediate Byte
1665 // FIXME: Setting the hasSideEffects flag here to match current behaviour.
1666 let hasSideEffects = 1 in
1667 def XXSPLTIB : X_RD6_IMM8<60, 360, (outs vsrc:$XT), (ins u8imm:$IMM8),
1668 "xxspltib $XT, $IMM8", IIC_VecPerm, []>;
1670 // When adding new D-Form loads/stores, be sure to update the ImmToIdxMap in
1671 // PPCRegisterInfo::PPCRegisterInfo and maybe save yourself some debugging.
1672 let mayLoad = 1, mayStore = 0 in {
1674 def LXV : DQ_RD6_RS5_DQ12<61, 1, (outs vsrc:$XT), (ins memrix16:$src),
1675 "lxv $XT, $src", IIC_LdStLFD, []>;
1677 def LXSD : DSForm_1<57, 2, (outs vfrc:$vD), (ins memrix:$src),
1678 "lxsd $vD, $src", IIC_LdStLFD, []>;
1679 // Load SP from src, convert it to DP, and place in dword[0]
1680 def LXSSP : DSForm_1<57, 3, (outs vfrc:$vD), (ins memrix:$src),
1681 "lxssp $vD, $src", IIC_LdStLFD, []>;
1683 // Load as Integer Byte/Halfword & Zero Indexed
1684 def LXSIBZX : X_XT6_RA5_RB5<31, 781, "lxsibzx", vsfrc,
1685 [(set f64:$XT, (PPClxsizx ForceXForm:$src, 1))]>;
1686 def LXSIHZX : X_XT6_RA5_RB5<31, 813, "lxsihzx", vsfrc,
1687 [(set f64:$XT, (PPClxsizx ForceXForm:$src, 2))]>;
1689 // Load Vector Halfword*8/Byte*16 Indexed
1690 def LXVH8X : X_XT6_RA5_RB5<31, 812, "lxvh8x" , vsrc, []>;
1691 def LXVB16X : X_XT6_RA5_RB5<31, 876, "lxvb16x", vsrc, []>;
1693 // Load Vector Indexed
1694 def LXVX : X_XT6_RA5_RB5<31, 268, "lxvx" , vsrc,
1695 [(set v2f64:$XT, (load XForm:$src))]>;
1696 // Load Vector (Left-justified) with Length
1697 def LXVL : XX1Form_memOp<31, 269, (outs vsrc:$XT), (ins memr:$src, g8rc:$rB),
1698 "lxvl $XT, $src, $rB", IIC_LdStLoad,
1699 [(set v4i32:$XT, (int_ppc_vsx_lxvl addr:$src, i64:$rB))]>;
1700 def LXVLL : XX1Form_memOp<31,301, (outs vsrc:$XT), (ins memr:$src, g8rc:$rB),
1701 "lxvll $XT, $src, $rB", IIC_LdStLoad,
1702 [(set v4i32:$XT, (int_ppc_vsx_lxvll addr:$src, i64:$rB))]>;
1704 // Load Vector Word & Splat Indexed
1705 def LXVWSX : X_XT6_RA5_RB5<31, 364, "lxvwsx" , vsrc, []>;
1708 // When adding new D-Form loads/stores, be sure to update the ImmToIdxMap in
1709 // PPCRegisterInfo::PPCRegisterInfo and maybe save yourself some debugging.
1710 let mayStore = 1, mayLoad = 0 in {
1712 def STXV : DQ_RD6_RS5_DQ12<61, 5, (outs), (ins vsrc:$XT, memrix16:$dst),
1713 "stxv $XT, $dst", IIC_LdStSTFD, []>;
1715 def STXSD : DSForm_1<61, 2, (outs), (ins vfrc:$vS, memrix:$dst),
1716 "stxsd $vS, $dst", IIC_LdStSTFD, []>;
1717 // Convert DP of dword[0] to SP, and Store to dst
1718 def STXSSP : DSForm_1<61, 3, (outs), (ins vfrc:$vS, memrix:$dst),
1719 "stxssp $vS, $dst", IIC_LdStSTFD, []>;
1721 // Store as Integer Byte/Halfword Indexed
1722 def STXSIBX : X_XS6_RA5_RB5<31, 909, "stxsibx" , vsfrc,
1723 [(PPCstxsix f64:$XT, ForceXForm:$dst, 1)]>;
1724 def STXSIHX : X_XS6_RA5_RB5<31, 941, "stxsihx" , vsfrc,
1725 [(PPCstxsix f64:$XT, ForceXForm:$dst, 2)]>;
1726 let isCodeGenOnly = 1 in {
1727 def STXSIBXv : X_XS6_RA5_RB5<31, 909, "stxsibx" , vsrc, []>;
1728 def STXSIHXv : X_XS6_RA5_RB5<31, 941, "stxsihx" , vsrc, []>;
1731 // Store Vector Halfword*8/Byte*16 Indexed
1732 def STXVH8X : X_XS6_RA5_RB5<31, 940, "stxvh8x" , vsrc, []>;
1733 def STXVB16X : X_XS6_RA5_RB5<31, 1004, "stxvb16x", vsrc, []>;
1735 // Store Vector Indexed
1736 def STXVX : X_XS6_RA5_RB5<31, 396, "stxvx" , vsrc,
1737 [(store v2f64:$XT, XForm:$dst)]>;
1739 // Store Vector (Left-justified) with Length
1740 def STXVL : XX1Form_memOp<31, 397, (outs),
1741 (ins vsrc:$XT, memr:$dst, g8rc:$rB),
1742 "stxvl $XT, $dst, $rB", IIC_LdStLoad,
1743 [(int_ppc_vsx_stxvl v4i32:$XT, addr:$dst,
1745 def STXVLL : XX1Form_memOp<31, 429, (outs),
1746 (ins vsrc:$XT, memr:$dst, g8rc:$rB),
1747 "stxvll $XT, $dst, $rB", IIC_LdStLoad,
1748 [(int_ppc_vsx_stxvll v4i32:$XT, addr:$dst,
1752 def DFLOADf32 : PPCPostRAExpPseudo<(outs vssrc:$XT), (ins memrix:$src),
1754 [(set f32:$XT, (load DSForm:$src))]>;
1755 def DFLOADf64 : PPCPostRAExpPseudo<(outs vsfrc:$XT), (ins memrix:$src),
1757 [(set f64:$XT, (load DSForm:$src))]>;
1758 def DFSTOREf32 : PPCPostRAExpPseudo<(outs), (ins vssrc:$XT, memrix:$dst),
1760 [(store f32:$XT, DSForm:$dst)]>;
1761 def DFSTOREf64 : PPCPostRAExpPseudo<(outs), (ins vsfrc:$XT, memrix:$dst),
1763 [(store f64:$XT, DSForm:$dst)]>;
1765 let mayStore = 1 in {
1766 def SPILLTOVSR_STX : PseudoXFormMemOp<(outs),
1767 (ins spilltovsrrc:$XT, memrr:$dst),
1768 "#SPILLTOVSR_STX", []>;
1769 def SPILLTOVSR_ST : PPCPostRAExpPseudo<(outs), (ins spilltovsrrc:$XT, memrix:$dst),
1770 "#SPILLTOVSR_ST", []>;
1772 let mayLoad = 1 in {
1773 def SPILLTOVSR_LDX : PseudoXFormMemOp<(outs spilltovsrrc:$XT),
1775 "#SPILLTOVSR_LDX", []>;
1776 def SPILLTOVSR_LD : PPCPostRAExpPseudo<(outs spilltovsrrc:$XT), (ins memrix:$src),
1777 "#SPILLTOVSR_LD", []>;
1781 } // hasSideEffects = 0
1783 let PPC970_Single = 1, AddedComplexity = 400 in {
1785 def SELECT_CC_VSRC: PPCCustomInserterPseudo<(outs vsrc:$dst),
1786 (ins crrc:$cond, vsrc:$T, vsrc:$F, i32imm:$BROPC),
1789 def SELECT_VSRC: PPCCustomInserterPseudo<(outs vsrc:$dst),
1790 (ins crbitrc:$cond, vsrc:$T, vsrc:$F),
1793 (select i1:$cond, v2f64:$T, v2f64:$F))]>;
1794 def SELECT_CC_VSFRC: PPCCustomInserterPseudo<(outs f8rc:$dst),
1795 (ins crrc:$cond, f8rc:$T, f8rc:$F,
1796 i32imm:$BROPC), "#SELECT_CC_VSFRC",
1798 def SELECT_VSFRC: PPCCustomInserterPseudo<(outs f8rc:$dst),
1799 (ins crbitrc:$cond, f8rc:$T, f8rc:$F),
1802 (select i1:$cond, f64:$T, f64:$F))]>;
1803 def SELECT_CC_VSSRC: PPCCustomInserterPseudo<(outs f4rc:$dst),
1804 (ins crrc:$cond, f4rc:$T, f4rc:$F,
1805 i32imm:$BROPC), "#SELECT_CC_VSSRC",
1807 def SELECT_VSSRC: PPCCustomInserterPseudo<(outs f4rc:$dst),
1808 (ins crbitrc:$cond, f4rc:$T, f4rc:$F),
1811 (select i1:$cond, f32:$T, f32:$F))]>;
1815 //----------------------------- DAG Definitions ------------------------------//
1817 // Output dag used to bitcast f32 to i32 and f64 to i64
1819 dag FltToInt = (i32 (MFVSRWZ (EXTRACT_SUBREG (XSCVDPSPN $A), sub_64)));
1820 dag DblToLong = (i64 (MFVSRD $A));
1824 dag F32Min = (COPY_TO_REGCLASS (XSMINDP (COPY_TO_REGCLASS $A, VSFRC),
1825 (COPY_TO_REGCLASS $B, VSFRC)),
1827 dag F32Max = (COPY_TO_REGCLASS (XSMAXDP (COPY_TO_REGCLASS $A, VSFRC),
1828 (COPY_TO_REGCLASS $B, VSFRC)),
1833 dag Li8 = (i32 (extloadi8 ForceXForm:$src));
1834 dag ZELi8 = (i32 (zextloadi8 ForceXForm:$src));
1835 dag ZELi8i64 = (i64 (zextloadi8 ForceXForm:$src));
1836 dag SELi8 = (i32 (sext_inreg (extloadi8 ForceXForm:$src), i8));
1837 dag SELi8i64 = (i64 (sext_inreg (extloadi8 ForceXForm:$src), i8));
1839 dag Li16 = (i32 (extloadi16 ForceXForm:$src));
1840 dag ZELi16 = (i32 (zextloadi16 ForceXForm:$src));
1841 dag ZELi16i64 = (i64 (zextloadi16 ForceXForm:$src));
1842 dag SELi16 = (i32 (sextloadi16 ForceXForm:$src));
1843 dag SELi16i64 = (i64 (sextloadi16 ForceXForm:$src));
1845 dag Li32 = (i32 (load ForceXForm:$src));
1848 def DWToSPExtractConv {
1849 dag El0US1 = (f32 (PPCfcfidus
1850 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S1, 0))))));
1851 dag El1US1 = (f32 (PPCfcfidus
1852 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S1, 1))))));
1853 dag El0US2 = (f32 (PPCfcfidus
1854 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S2, 0))))));
1855 dag El1US2 = (f32 (PPCfcfidus
1856 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S2, 1))))));
1857 dag El0SS1 = (f32 (PPCfcfids
1858 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S1, 0))))));
1859 dag El1SS1 = (f32 (PPCfcfids
1860 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S1, 1))))));
1861 dag El0SS2 = (f32 (PPCfcfids
1862 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S2, 0))))));
1863 dag El1SS2 = (f32 (PPCfcfids
1864 (f64 (PPCmtvsra (i64 (vector_extract v2i64:$S2, 1))))));
1865 dag BVU = (v4f32 (build_vector El0US1, El1US1, El0US2, El1US2));
1866 dag BVS = (v4f32 (build_vector El0SS1, El1SS1, El0SS2, El1SS2));
1869 def WToDPExtractConv {
1870 dag El0S = (f64 (PPCfcfid (PPCmtvsra (extractelt v4i32:$A, 0))));
1871 dag El1S = (f64 (PPCfcfid (PPCmtvsra (extractelt v4i32:$A, 1))));
1872 dag El2S = (f64 (PPCfcfid (PPCmtvsra (extractelt v4i32:$A, 2))));
1873 dag El3S = (f64 (PPCfcfid (PPCmtvsra (extractelt v4i32:$A, 3))));
1874 dag El0U = (f64 (PPCfcfidu (PPCmtvsrz (extractelt v4i32:$A, 0))));
1875 dag El1U = (f64 (PPCfcfidu (PPCmtvsrz (extractelt v4i32:$A, 1))));
1876 dag El2U = (f64 (PPCfcfidu (PPCmtvsrz (extractelt v4i32:$A, 2))));
1877 dag El3U = (f64 (PPCfcfidu (PPCmtvsrz (extractelt v4i32:$A, 3))));
1878 dag BV02S = (v2f64 (build_vector El0S, El2S));
1879 dag BV13S = (v2f64 (build_vector El1S, El3S));
1880 dag BV02U = (v2f64 (build_vector El0U, El2U));
1881 dag BV13U = (v2f64 (build_vector El1U, El3U));
1884 /* Direct moves of various widths from GPR's into VSR's. Each move lines
1885 the value up into element 0 (both BE and LE). Namely, entities smaller than
1886 a doubleword are shifted left and moved for BE. For LE, they're moved, then
1887 swapped to go into the least significant element of the VSR.
1893 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $A, sub_32), 56, 7));
1897 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $A, sub_32), 48, 15));
1901 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $A, sub_32), 32, 31));
1902 dag BE_DWORD_0 = (MTVSRD $A);
1904 dag LE_MTVSRW = (MTVSRD (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $A, sub_32));
1905 dag LE_WORD_1 = (v2i64 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
1906 LE_MTVSRW, sub_64));
1907 dag LE_WORD_0 = (XXPERMDI LE_WORD_1, LE_WORD_1, 2);
1908 dag LE_DWORD_1 = (v2i64 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
1909 BE_DWORD_0, sub_64));
1910 dag LE_DWORD_0 = (XXPERMDI LE_DWORD_1, LE_DWORD_1, 2);
1913 /* Patterns for extracting elements out of vectors. Integer elements are
1914 extracted using direct move operations. Patterns for extracting elements
1915 whose indices are not available at compile time are also provided with
1916 various _VARIABLE_ patterns.
1917 The numbering for the DAG's is for LE, but when used on BE, the correct
1918 LE element can just be used (i.e. LE_BYTE_2 == BE_BYTE_13).
1920 def VectorExtractions {
1921 // Doubleword extraction
1925 (XXPERMDI (COPY_TO_REGCLASS $S, VSRC),
1926 (COPY_TO_REGCLASS $S, VSRC), 2), sub_64));
1927 dag LE_DWORD_1 = (MFVSRD
1929 (v2i64 (COPY_TO_REGCLASS $S, VSRC)), sub_64));
1932 dag LE_WORD_0 = (MFVSRWZ (EXTRACT_SUBREG (XXPERMDI $S, $S, 2), sub_64));
1933 dag LE_WORD_1 = (MFVSRWZ (EXTRACT_SUBREG (XXSLDWI $S, $S, 1), sub_64));
1934 dag LE_WORD_2 = (MFVSRWZ (EXTRACT_SUBREG
1935 (v2i64 (COPY_TO_REGCLASS $S, VSRC)), sub_64));
1936 dag LE_WORD_3 = (MFVSRWZ (EXTRACT_SUBREG (XXSLDWI $S, $S, 3), sub_64));
1938 // Halfword extraction
1939 dag LE_HALF_0 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 0, 48), sub_32));
1940 dag LE_HALF_1 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 48, 48), sub_32));
1941 dag LE_HALF_2 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 32, 48), sub_32));
1942 dag LE_HALF_3 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 16, 48), sub_32));
1943 dag LE_HALF_4 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 0, 48), sub_32));
1944 dag LE_HALF_5 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 48, 48), sub_32));
1945 dag LE_HALF_6 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 32, 48), sub_32));
1946 dag LE_HALF_7 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 16, 48), sub_32));
1949 dag LE_BYTE_0 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 0, 56), sub_32));
1950 dag LE_BYTE_1 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 56, 56), sub_32));
1951 dag LE_BYTE_2 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 48, 56), sub_32));
1952 dag LE_BYTE_3 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 40, 56), sub_32));
1953 dag LE_BYTE_4 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 32, 56), sub_32));
1954 dag LE_BYTE_5 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 24, 56), sub_32));
1955 dag LE_BYTE_6 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 16, 56), sub_32));
1956 dag LE_BYTE_7 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_0, 8, 56), sub_32));
1957 dag LE_BYTE_8 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 0, 56), sub_32));
1958 dag LE_BYTE_9 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 56, 56), sub_32));
1959 dag LE_BYTE_10 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 48, 56), sub_32));
1960 dag LE_BYTE_11 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 40, 56), sub_32));
1961 dag LE_BYTE_12 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 32, 56), sub_32));
1962 dag LE_BYTE_13 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 24, 56), sub_32));
1963 dag LE_BYTE_14 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 16, 56), sub_32));
1964 dag LE_BYTE_15 = (i32 (EXTRACT_SUBREG (RLDICL LE_DWORD_1, 8, 56), sub_32));
1966 /* Variable element number (BE and LE patterns must be specified separately)
1967 This is a rather involved process.
1969 Conceptually, this is how the move is accomplished:
1970 1. Identify which doubleword contains the element
1971 2. Shift in the VMX register so that the correct doubleword is correctly
1972 lined up for the MFVSRD
1973 3. Perform the move so that the element (along with some extra stuff)
1975 4. Right shift within the GPR so that the element is right-justified
1977 Of course, the index is an element number which has a different meaning
1978 on LE/BE so the patterns have to be specified separately.
1980 Note: The final result will be the element right-justified with high
1981 order bits being arbitrarily defined (namely, whatever was in the
1982 vector register to the left of the value originally).
1987 - For elements 0-7, we shift left by 8 bytes since they're on the right
1988 - For elements 8-15, we need not shift (shift left by zero bytes)
1989 This is accomplished by inverting the bits of the index and AND-ing
1990 with 0x8 (i.e. clearing all bits of the index and inverting bit 60).
1992 dag LE_VBYTE_PERM_VEC = (v16i8 (LVSL ZERO8, (ANDC8 (LI8 8), $Idx)));
1995 // - Now that we set up the shift amount, we shift in the VMX register
1996 dag LE_VBYTE_PERMUTE = (v16i8 (VPERM $S, $S, LE_VBYTE_PERM_VEC));
1999 // - The doubleword containing our element is moved to a GPR
2000 dag LE_MV_VBYTE = (MFVSRD
2002 (v2i64 (COPY_TO_REGCLASS LE_VBYTE_PERMUTE, VSRC)),
2006 - Truncate the element number to the range 0-7 (8-15 are symmetrical
2007 and out of range values are truncated accordingly)
2008 - Multiply by 8 as we need to shift right by the number of bits, not bytes
2009 - Shift right in the GPR by the calculated value
2011 dag LE_VBYTE_SHIFT = (EXTRACT_SUBREG (RLDICR (AND8 (LI8 7), $Idx), 3, 60),
2013 dag LE_VARIABLE_BYTE = (EXTRACT_SUBREG (SRD LE_MV_VBYTE, LE_VBYTE_SHIFT),
2016 /* LE variable halfword
2018 - For elements 0-3, we shift left by 8 since they're on the right
2019 - For elements 4-7, we need not shift (shift left by zero bytes)
2020 Similarly to the byte pattern, we invert the bits of the index, but we
2021 AND with 0x4 (i.e. clear all bits of the index and invert bit 61).
2022 Of course, the shift is still by 8 bytes, so we must multiply by 2.
2024 dag LE_VHALF_PERM_VEC =
2025 (v16i8 (LVSL ZERO8, (RLDICR (ANDC8 (LI8 4), $Idx), 1, 62)));
2028 // - Now that we set up the shift amount, we shift in the VMX register
2029 dag LE_VHALF_PERMUTE = (v16i8 (VPERM $S, $S, LE_VHALF_PERM_VEC));
2032 // - The doubleword containing our element is moved to a GPR
2033 dag LE_MV_VHALF = (MFVSRD
2035 (v2i64 (COPY_TO_REGCLASS LE_VHALF_PERMUTE, VSRC)),
2039 - Truncate the element number to the range 0-3 (4-7 are symmetrical
2040 and out of range values are truncated accordingly)
2041 - Multiply by 16 as we need to shift right by the number of bits
2042 - Shift right in the GPR by the calculated value
2044 dag LE_VHALF_SHIFT = (EXTRACT_SUBREG (RLDICR (AND8 (LI8 3), $Idx), 4, 59),
2046 dag LE_VARIABLE_HALF = (EXTRACT_SUBREG (SRD LE_MV_VHALF, LE_VHALF_SHIFT),
2051 - For elements 0-1, we shift left by 8 since they're on the right
2052 - For elements 2-3, we need not shift
2054 dag LE_VWORD_PERM_VEC = (v16i8 (LVSL ZERO8,
2055 (RLDICR (ANDC8 (LI8 2), $Idx), 2, 61)));
2058 // - Now that we set up the shift amount, we shift in the VMX register
2059 dag LE_VWORD_PERMUTE = (v16i8 (VPERM $S, $S, LE_VWORD_PERM_VEC));
2062 // - The doubleword containing our element is moved to a GPR
2063 dag LE_MV_VWORD = (MFVSRD
2065 (v2i64 (COPY_TO_REGCLASS LE_VWORD_PERMUTE, VSRC)),
2069 - Truncate the element number to the range 0-1 (2-3 are symmetrical
2070 and out of range values are truncated accordingly)
2071 - Multiply by 32 as we need to shift right by the number of bits
2072 - Shift right in the GPR by the calculated value
2074 dag LE_VWORD_SHIFT = (EXTRACT_SUBREG (RLDICR (AND8 (LI8 1), $Idx), 5, 58),
2076 dag LE_VARIABLE_WORD = (EXTRACT_SUBREG (SRD LE_MV_VWORD, LE_VWORD_SHIFT),
2079 /* LE variable doubleword
2081 - For element 0, we shift left by 8 since it's on the right
2082 - For element 1, we need not shift
2084 dag LE_VDWORD_PERM_VEC = (v16i8 (LVSL ZERO8,
2085 (RLDICR (ANDC8 (LI8 1), $Idx), 3, 60)));
2088 // - Now that we set up the shift amount, we shift in the VMX register
2089 dag LE_VDWORD_PERMUTE = (v16i8 (VPERM $S, $S, LE_VDWORD_PERM_VEC));
2092 // - The doubleword containing our element is moved to a GPR
2093 // - Number 4. is not needed for the doubleword as the value is 64-bits
2094 dag LE_VARIABLE_DWORD =
2095 (MFVSRD (EXTRACT_SUBREG
2096 (v2i64 (COPY_TO_REGCLASS LE_VDWORD_PERMUTE, VSRC)),
2099 /* LE variable float
2100 - Shift the vector to line up the desired element to BE Word 0
2101 - Convert 32-bit float to a 64-bit single precision float
2103 dag LE_VFLOAT_PERM_VEC = (v16i8 (LVSL ZERO8,
2104 (RLDICR (XOR8 (LI8 3), $Idx), 2, 61)));
2105 dag LE_VFLOAT_PERMUTE = (VPERM $S, $S, LE_VFLOAT_PERM_VEC);
2106 dag LE_VARIABLE_FLOAT = (XSCVSPDPN LE_VFLOAT_PERMUTE);
2108 /* LE variable double
2109 Same as the LE doubleword except there is no move.
2111 dag LE_VDOUBLE_PERMUTE = (v16i8 (VPERM (v16i8 (COPY_TO_REGCLASS $S, VRRC)),
2112 (v16i8 (COPY_TO_REGCLASS $S, VRRC)),
2113 LE_VDWORD_PERM_VEC));
2114 dag LE_VARIABLE_DOUBLE = (COPY_TO_REGCLASS LE_VDOUBLE_PERMUTE, VSRC);
2117 The algorithm here is the same as the LE variable byte except:
2118 - The shift in the VMX register is by 0/8 for opposite element numbers so
2119 we simply AND the element number with 0x8
2120 - The order of elements after the move to GPR is reversed, so we invert
2121 the bits of the index prior to truncating to the range 0-7
2123 dag BE_VBYTE_PERM_VEC = (v16i8 (LVSL ZERO8, (ANDI8_rec $Idx, 8)));
2124 dag BE_VBYTE_PERMUTE = (v16i8 (VPERM $S, $S, BE_VBYTE_PERM_VEC));
2125 dag BE_MV_VBYTE = (MFVSRD
2127 (v2i64 (COPY_TO_REGCLASS BE_VBYTE_PERMUTE, VSRC)),
2129 dag BE_VBYTE_SHIFT = (EXTRACT_SUBREG (RLDICR (ANDC8 (LI8 7), $Idx), 3, 60),
2131 dag BE_VARIABLE_BYTE = (EXTRACT_SUBREG (SRD BE_MV_VBYTE, BE_VBYTE_SHIFT),
2134 /* BE variable halfword
2135 The algorithm here is the same as the LE variable halfword except:
2136 - The shift in the VMX register is by 0/8 for opposite element numbers so
2137 we simply AND the element number with 0x4 and multiply by 2
2138 - The order of elements after the move to GPR is reversed, so we invert
2139 the bits of the index prior to truncating to the range 0-3
2141 dag BE_VHALF_PERM_VEC = (v16i8 (LVSL ZERO8,
2142 (RLDICR (ANDI8_rec $Idx, 4), 1, 62)));
2143 dag BE_VHALF_PERMUTE = (v16i8 (VPERM $S, $S, BE_VHALF_PERM_VEC));
2144 dag BE_MV_VHALF = (MFVSRD
2146 (v2i64 (COPY_TO_REGCLASS BE_VHALF_PERMUTE, VSRC)),
2148 dag BE_VHALF_SHIFT = (EXTRACT_SUBREG (RLDICR (ANDC8 (LI8 3), $Idx), 4, 59),
2150 dag BE_VARIABLE_HALF = (EXTRACT_SUBREG (SRD BE_MV_VHALF, BE_VHALF_SHIFT),
2154 The algorithm is the same as the LE variable word except:
2155 - The shift in the VMX register happens for opposite element numbers
2156 - The order of elements after the move to GPR is reversed, so we invert
2157 the bits of the index prior to truncating to the range 0-1
2159 dag BE_VWORD_PERM_VEC = (v16i8 (LVSL ZERO8,
2160 (RLDICR (ANDI8_rec $Idx, 2), 2, 61)));
2161 dag BE_VWORD_PERMUTE = (v16i8 (VPERM $S, $S, BE_VWORD_PERM_VEC));
2162 dag BE_MV_VWORD = (MFVSRD
2164 (v2i64 (COPY_TO_REGCLASS BE_VWORD_PERMUTE, VSRC)),
2166 dag BE_VWORD_SHIFT = (EXTRACT_SUBREG (RLDICR (ANDC8 (LI8 1), $Idx), 5, 58),
2168 dag BE_VARIABLE_WORD = (EXTRACT_SUBREG (SRD BE_MV_VWORD, BE_VWORD_SHIFT),
2171 /* BE variable doubleword
2172 Same as the LE doubleword except we shift in the VMX register for opposite
2175 dag BE_VDWORD_PERM_VEC = (v16i8 (LVSL ZERO8,
2176 (RLDICR (ANDI8_rec $Idx, 1), 3, 60)));
2177 dag BE_VDWORD_PERMUTE = (v16i8 (VPERM $S, $S, BE_VDWORD_PERM_VEC));
2178 dag BE_VARIABLE_DWORD =
2179 (MFVSRD (EXTRACT_SUBREG
2180 (v2i64 (COPY_TO_REGCLASS BE_VDWORD_PERMUTE, VSRC)),
2183 /* BE variable float
2184 - Shift the vector to line up the desired element to BE Word 0
2185 - Convert 32-bit float to a 64-bit single precision float
2187 dag BE_VFLOAT_PERM_VEC = (v16i8 (LVSL ZERO8, (RLDICR $Idx, 2, 61)));
2188 dag BE_VFLOAT_PERMUTE = (VPERM $S, $S, BE_VFLOAT_PERM_VEC);
2189 dag BE_VARIABLE_FLOAT = (XSCVSPDPN BE_VFLOAT_PERMUTE);
2191 // BE variable float 32-bit version
2192 dag BE_32B_VFLOAT_PERM_VEC = (v16i8 (LVSL (i32 ZERO), (RLWINM $Idx, 2, 0, 29)));
2193 dag BE_32B_VFLOAT_PERMUTE = (VPERM $S, $S, BE_32B_VFLOAT_PERM_VEC);
2194 dag BE_32B_VARIABLE_FLOAT = (XSCVSPDPN BE_32B_VFLOAT_PERMUTE);
2196 /* BE variable double
2197 Same as the BE doubleword except there is no move.
2199 dag BE_VDOUBLE_PERMUTE = (v16i8 (VPERM (v16i8 (COPY_TO_REGCLASS $S, VRRC)),
2200 (v16i8 (COPY_TO_REGCLASS $S, VRRC)),
2201 BE_VDWORD_PERM_VEC));
2202 dag BE_VARIABLE_DOUBLE = (COPY_TO_REGCLASS BE_VDOUBLE_PERMUTE, VSRC);
2204 // BE variable double 32-bit version
2205 dag BE_32B_VDWORD_PERM_VEC = (v16i8 (LVSL (i32 ZERO),
2206 (RLWINM (ANDI_rec $Idx, 1), 3, 0, 28)));
2207 dag BE_32B_VDOUBLE_PERMUTE = (v16i8 (VPERM (v16i8 (COPY_TO_REGCLASS $S, VRRC)),
2208 (v16i8 (COPY_TO_REGCLASS $S, VRRC)),
2209 BE_32B_VDWORD_PERM_VEC));
2210 dag BE_32B_VARIABLE_DOUBLE = (COPY_TO_REGCLASS BE_32B_VDOUBLE_PERMUTE, VSRC);
2214 dag F32_TO_BE_WORD1 = (v4f32 (XSCVDPSPN $B));
2215 dag I32_TO_BE_WORD1 = (SUBREG_TO_REG (i64 1), (MTVSRWZ $B), sub_64);
2218 // Integer extend helper dags 32 -> 64
2220 dag A = (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $A, sub_32);
2221 dag B = (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $B, sub_32);
2222 dag C = (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $C, sub_32);
2223 dag D = (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $D, sub_32);
2227 dag A0 = (f32 (any_fpround (f64 (extractelt v2f64:$A, 0))));
2228 dag A1 = (f32 (any_fpround (f64 (extractelt v2f64:$A, 1))));
2229 dag B0 = (f32 (any_fpround (f64 (extractelt v2f64:$B, 0))));
2230 dag B1 = (f32 (any_fpround (f64 (extractelt v2f64:$B, 1))));
2234 dag A0S = (i32 (PPCmfvsr (f64 (PPCfctiwz (f64 (extractelt v2f64:$A, 0))))));
2235 dag A1S = (i32 (PPCmfvsr (f64 (PPCfctiwz (f64 (extractelt v2f64:$A, 1))))));
2236 dag B0S = (i32 (PPCmfvsr (f64 (PPCfctiwz (f64 (extractelt v2f64:$B, 0))))));
2237 dag B1S = (i32 (PPCmfvsr (f64 (PPCfctiwz (f64 (extractelt v2f64:$B, 1))))));
2238 dag A0U = (i32 (PPCmfvsr (f64 (PPCfctiwuz (f64 (extractelt v2f64:$A, 0))))));
2239 dag A1U = (i32 (PPCmfvsr (f64 (PPCfctiwuz (f64 (extractelt v2f64:$A, 1))))));
2240 dag B0U = (i32 (PPCmfvsr (f64 (PPCfctiwuz (f64 (extractelt v2f64:$B, 0))))));
2241 dag B1U = (i32 (PPCmfvsr (f64 (PPCfctiwuz (f64 (extractelt v2f64:$B, 1))))));
2245 dag LE_A0 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 0)), i8));
2246 dag LE_A1 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 4)), i8));
2247 dag LE_A2 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 8)), i8));
2248 dag LE_A3 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 12)), i8));
2249 dag BE_A0 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 3)), i8));
2250 dag BE_A1 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 7)), i8));
2251 dag BE_A2 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 11)), i8));
2252 dag BE_A3 = (i32 (sext_inreg (i32 (vector_extract v16i8:$A, 15)), i8));
2256 dag LE_A0 = (i64 (sext_inreg
2257 (i64 (anyext (i32 (vector_extract v16i8:$A, 0)))), i8));
2258 dag LE_A1 = (i64 (sext_inreg
2259 (i64 (anyext (i32 (vector_extract v16i8:$A, 8)))), i8));
2260 dag BE_A0 = (i64 (sext_inreg
2261 (i64 (anyext (i32 (vector_extract v16i8:$A, 7)))), i8));
2262 dag BE_A1 = (i64 (sext_inreg
2263 (i64 (anyext (i32 (vector_extract v16i8:$A, 15)))), i8));
2267 dag LE_A0 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 0)), i16));
2268 dag LE_A1 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 2)), i16));
2269 dag LE_A2 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 4)), i16));
2270 dag LE_A3 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 6)), i16));
2271 dag BE_A0 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 1)), i16));
2272 dag BE_A1 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 3)), i16));
2273 dag BE_A2 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 5)), i16));
2274 dag BE_A3 = (i32 (sext_inreg (i32 (vector_extract v8i16:$A, 7)), i16));
2278 dag LE_A0 = (i64 (sext_inreg
2279 (i64 (anyext (i32 (vector_extract v8i16:$A, 0)))), i16));
2280 dag LE_A1 = (i64 (sext_inreg
2281 (i64 (anyext (i32 (vector_extract v8i16:$A, 4)))), i16));
2282 dag BE_A0 = (i64 (sext_inreg
2283 (i64 (anyext (i32 (vector_extract v8i16:$A, 3)))), i16));
2284 dag BE_A1 = (i64 (sext_inreg
2285 (i64 (anyext (i32 (vector_extract v8i16:$A, 7)))), i16));
2289 dag LE_A0 = (i64 (sext (i32 (vector_extract v4i32:$A, 0))));
2290 dag LE_A1 = (i64 (sext (i32 (vector_extract v4i32:$A, 2))));
2291 dag BE_A0 = (i64 (sext (i32 (vector_extract v4i32:$A, 1))));
2292 dag BE_A1 = (i64 (sext (i32 (vector_extract v4i32:$A, 3))));
2296 dag A = (i32 (PPCmfvsr (PPCfctiwz (f64 (extloadf32 ForceXForm:$A)))));
2299 dag A = (i32 (PPCmfvsr (PPCfctiwuz (f64 (extloadf32 ForceXForm:$A)))));
2302 dag A = (i64 (PPCmfvsr (PPCfctidz (f64 (extloadf32 ForceXForm:$A)))));
2304 def FltToLongLoadP9 {
2305 dag A = (i64 (PPCmfvsr (PPCfctidz (f64 (extloadf32 DSForm:$A)))));
2307 def FltToULongLoad {
2308 dag A = (i64 (PPCmfvsr (PPCfctiduz (f64 (extloadf32 ForceXForm:$A)))));
2310 def FltToULongLoadP9 {
2311 dag A = (i64 (PPCmfvsr (PPCfctiduz (f64 (extloadf32 DSForm:$A)))));
2314 dag A = (i64 (PPCmfvsr (f64 (PPCfctidz (fpextend f32:$A)))));
2317 dag A = (i64 (PPCmfvsr (f64 (PPCfctiduz (fpextend f32:$A)))));
2320 dag A = (i32 (PPCmfvsr (f64 (PPCfctiwz f64:$A))));
2321 dag B = (i32 (PPCmfvsr (f64 (PPCfctiwz f64:$B))));
2322 dag C = (i32 (PPCmfvsr (f64 (PPCfctiwz f64:$C))));
2323 dag D = (i32 (PPCmfvsr (f64 (PPCfctiwz f64:$D))));
2326 dag A = (i32 (PPCmfvsr (f64 (PPCfctiwuz f64:$A))));
2327 dag B = (i32 (PPCmfvsr (f64 (PPCfctiwuz f64:$B))));
2328 dag C = (i32 (PPCmfvsr (f64 (PPCfctiwuz f64:$C))));
2329 dag D = (i32 (PPCmfvsr (f64 (PPCfctiwuz f64:$D))));
2332 dag A = (i64 (PPCmfvsr (f64 (PPCfctidz f64:$A))));
2335 dag A = (i64 (PPCmfvsr (f64 (PPCfctiduz f64:$A))));
2338 dag A = (i32 (PPCmfvsr (PPCfctiwz (f64 (load ForceXForm:$A)))));
2340 def DblToIntLoadP9 {
2341 dag A = (i32 (PPCmfvsr (PPCfctiwz (f64 (load DSForm:$A)))));
2344 dag A = (i32 (PPCmfvsr (PPCfctiwuz (f64 (load ForceXForm:$A)))));
2346 def DblToUIntLoadP9 {
2347 dag A = (i32 (PPCmfvsr (PPCfctiwuz (f64 (load DSForm:$A)))));
2350 dag A = (i64 (PPCmfvsr (PPCfctidz (f64 (load ForceXForm:$A)))));
2352 def DblToULongLoad {
2353 dag A = (i64 (PPCmfvsr (PPCfctiduz (f64 (load ForceXForm:$A)))));
2356 // FP load dags (for f32 -> v4f32)
2358 dag A = (f32 (load ForceXForm:$A));
2359 dag B = (f32 (load ForceXForm:$B));
2360 dag C = (f32 (load ForceXForm:$C));
2361 dag D = (f32 (load ForceXForm:$D));
2364 // FP merge dags (for f32 -> v4f32)
2366 dag LD32A = (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$A), sub_64);
2367 dag LD32B = (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$B), sub_64);
2368 dag LD32C = (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$C), sub_64);
2369 dag LD32D = (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$D), sub_64);
2370 dag AC = (XVCVDPSP (XXPERMDI (SUBREG_TO_REG (i64 1), $A, sub_64),
2371 (SUBREG_TO_REG (i64 1), $C, sub_64), 0));
2372 dag BD = (XVCVDPSP (XXPERMDI (SUBREG_TO_REG (i64 1), $B, sub_64),
2373 (SUBREG_TO_REG (i64 1), $D, sub_64), 0));
2374 dag ABhToFlt = (XVCVDPSP (XXPERMDI $A, $B, 0));
2375 dag ABlToFlt = (XVCVDPSP (XXPERMDI $A, $B, 3));
2376 dag BAhToFlt = (XVCVDPSP (XXPERMDI $B, $A, 0));
2377 dag BAlToFlt = (XVCVDPSP (XXPERMDI $B, $A, 3));
2380 // Word-element merge dags - conversions from f64 to i32 merged into vectors.
2382 // For big endian, we merge low and hi doublewords (A, B).
2383 dag A0B0 = (v2f64 (XXPERMDI v2f64:$A, v2f64:$B, 0));
2384 dag A1B1 = (v2f64 (XXPERMDI v2f64:$A, v2f64:$B, 3));
2385 dag CVA1B1S = (v4i32 (XVCVDPSXWS A1B1));
2386 dag CVA0B0S = (v4i32 (XVCVDPSXWS A0B0));
2387 dag CVA1B1U = (v4i32 (XVCVDPUXWS A1B1));
2388 dag CVA0B0U = (v4i32 (XVCVDPUXWS A0B0));
2390 // For little endian, we merge low and hi doublewords (B, A).
2391 dag B1A1 = (v2f64 (XXPERMDI v2f64:$B, v2f64:$A, 0));
2392 dag B0A0 = (v2f64 (XXPERMDI v2f64:$B, v2f64:$A, 3));
2393 dag CVB1A1S = (v4i32 (XVCVDPSXWS B1A1));
2394 dag CVB0A0S = (v4i32 (XVCVDPSXWS B0A0));
2395 dag CVB1A1U = (v4i32 (XVCVDPUXWS B1A1));
2396 dag CVB0A0U = (v4i32 (XVCVDPUXWS B0A0));
2398 // For big endian, we merge hi doublewords of (A, C) and (B, D), convert
2400 dag AC = (v2f64 (XXPERMDI (SUBREG_TO_REG (i64 1), f64:$A, sub_64),
2401 (SUBREG_TO_REG (i64 1), f64:$C, sub_64), 0));
2402 dag BD = (v2f64 (XXPERMDI (SUBREG_TO_REG (i64 1), f64:$B, sub_64),
2403 (SUBREG_TO_REG (i64 1), f64:$D, sub_64), 0));
2404 dag CVACS = (v4i32 (XVCVDPSXWS AC));
2405 dag CVBDS = (v4i32 (XVCVDPSXWS BD));
2406 dag CVACU = (v4i32 (XVCVDPUXWS AC));
2407 dag CVBDU = (v4i32 (XVCVDPUXWS BD));
2409 // For little endian, we merge hi doublewords of (D, B) and (C, A), convert
2411 dag DB = (v2f64 (XXPERMDI (SUBREG_TO_REG (i64 1), f64:$D, sub_64),
2412 (SUBREG_TO_REG (i64 1), f64:$B, sub_64), 0));
2413 dag CA = (v2f64 (XXPERMDI (SUBREG_TO_REG (i64 1), f64:$C, sub_64),
2414 (SUBREG_TO_REG (i64 1), f64:$A, sub_64), 0));
2415 dag CVDBS = (v4i32 (XVCVDPSXWS DB));
2416 dag CVCAS = (v4i32 (XVCVDPSXWS CA));
2417 dag CVDBU = (v4i32 (XVCVDPUXWS DB));
2418 dag CVCAU = (v4i32 (XVCVDPUXWS CA));
2422 dag SGTW = (v2i64 (v2i64 (VCMPGTSW v2i64:$vA, v2i64:$vB)));
2423 dag UGTW = (v2i64 (v2i64 (VCMPGTUW v2i64:$vA, v2i64:$vB)));
2424 dag EQW = (v2i64 (v2i64 (VCMPEQUW v2i64:$vA, v2i64:$vB)));
2425 dag UGTWSHAND = (v2i64 (XXLAND (v2i64 (XXSLDWI UGTW, UGTW, 1)), EQW));
2426 dag EQWSHAND = (v2i64 (XXLAND (v2i64 (XXSLDWI EQW, EQW, 1)), EQW));
2427 dag SGTWOR = (v2i64 (XXLOR SGTW, UGTWSHAND));
2428 dag UGTWOR = (v2i64 (XXLOR UGTW, UGTWSHAND));
2429 dag MRGSGT = (v2i64 (XXPERMDI (v2i64 (XXSPLTW SGTWOR, 0)),
2430 (v2i64 (XXSPLTW SGTWOR, 2)), 0));
2431 dag MRGUGT = (v2i64 (XXPERMDI (v2i64 (XXSPLTW UGTWOR, 0)),
2432 (v2i64 (XXSPLTW UGTWOR, 2)), 0));
2433 dag MRGEQ = (v2i64 (XXPERMDI (v2i64 (XXSPLTW EQWSHAND, 0)),
2434 (v2i64 (XXSPLTW EQWSHAND, 2)), 0));
2437 //---------------------------- Anonymous Patterns ----------------------------//
2438 // Predicate combinations are kept in roughly chronological order in terms of
2439 // instruction availability in the architecture. For example, VSX came in with
2440 // ISA 2.06 (Power7). There have since been additions in ISA 2.07 (Power8) and
2441 // ISA 3.0 (Power9). However, the granularity of features on later subtargets
2442 // is finer for various reasons. For example, we have Power8Vector,
2443 // Power8Altivec, DirectMove that all came in with ISA 2.07. The situation is
2444 // similar with ISA 3.0 with Power9Vector, Power9Altivec, IsISA3_0. Then there
2445 // are orthogonal predicates such as endianness for which the order was
2446 // arbitrarily chosen to be Big, Little.
2448 // Predicate combinations available:
2449 // [HasVSX, IsLittleEndian, HasP8Altivec] Altivec patterns using VSX instr.
2450 // [HasVSX, IsBigEndian, HasP8Altivec] Altivec patterns using VSX instr.
2452 // [HasVSX, IsBigEndian]
2453 // [HasVSX, IsLittleEndian]
2454 // [HasVSX, NoP9Vector]
2455 // [HasVSX, NoP9Vector, IsLittleEndian]
2456 // [HasVSX, NoP9Vector, IsBigEndian]
2457 // [HasVSX, HasOnlySwappingMemOps]
2458 // [HasVSX, HasOnlySwappingMemOps, IsBigEndian]
2459 // [HasVSX, HasP8Vector]
2460 // [HasVSX, HasP8Vector, IsBigEndian]
2461 // [HasVSX, HasP8Vector, IsBigEndian, IsPPC64]
2462 // [HasVSX, HasP8Vector, IsLittleEndian]
2463 // [HasVSX, HasP8Vector, NoP9Vector, IsBigEndian, IsPPC64]
2464 // [HasVSX, HasP8Vector, NoP9Vector, IsLittleEndian]
2465 // [HasVSX, HasDirectMove]
2466 // [HasVSX, HasDirectMove, IsBigEndian]
2467 // [HasVSX, HasDirectMove, IsLittleEndian]
2468 // [HasVSX, HasDirectMove, NoP9Altivec, IsBigEndian, IsPPC64]
2469 // [HasVSX, HasDirectMove, NoP9Vector, IsBigEndian, IsPPC64]
2470 // [HasVSX, HasDirectMove, NoP9Altivec, IsLittleEndian]
2471 // [HasVSX, HasDirectMove, NoP9Vector, IsLittleEndian]
2472 // [HasVSX, HasP9Vector]
2473 // [HasVSX, HasP9Vector, NoP10Vector]
2474 // [HasVSX, HasP9Vector, IsBigEndian]
2475 // [HasVSX, HasP9Vector, IsBigEndian, IsPPC64]
2476 // [HasVSX, HasP9Vector, IsLittleEndian]
2477 // [HasVSX, HasP9Altivec]
2478 // [HasVSX, HasP9Altivec, IsBigEndian, IsPPC64]
2479 // [HasVSX, HasP9Altivec, IsLittleEndian]
2480 // [HasVSX, IsISA3_0, HasDirectMove, IsBigEndian, IsPPC64]
2481 // [HasVSX, IsISA3_0, HasDirectMove, IsLittleEndian]
2483 // These Altivec patterns are here because we need a VSX instruction to match
2484 // the intrinsic (but only for little endian system).
2485 let Predicates = [HasVSX, IsLittleEndian, HasP8Altivec] in
2486 def : Pat<(v16i8 (int_ppc_altivec_crypto_vpermxor v16i8:$a,
2487 v16i8:$b, v16i8:$c)),
2488 (v16i8 (VPERMXOR $a, $b, (XXLNOR (COPY_TO_REGCLASS $c, VSRC),
2489 (COPY_TO_REGCLASS $c, VSRC))))>;
2490 let Predicates = [HasVSX, IsBigEndian, HasP8Altivec] in
2491 def : Pat<(v16i8 (int_ppc_altivec_crypto_vpermxor v16i8:$a,
2492 v16i8:$b, v16i8:$c)),
2493 (v16i8 (VPERMXOR $a, $b, $c))>;
2495 let AddedComplexity = 400 in {
2496 // Valid for any VSX subtarget, regardless of endianness.
2497 let Predicates = [HasVSX] in {
2498 def : Pat<(v4i32 (vnot v4i32:$A)),
2499 (v4i32 (XXLNOR $A, $A))>;
2500 def : Pat<(v4i32 (or (and (vnot v4i32:$C), v4i32:$A),
2501 (and v4i32:$B, v4i32:$C))),
2502 (v4i32 (XXSEL $A, $B, $C))>;
2504 // Additional fnmsub pattern for PPC specific ISD opcode
2505 def : Pat<(PPCfnmsub f64:$A, f64:$B, f64:$C),
2506 (XSNMSUBADP $C, $A, $B)>;
2507 def : Pat<(fneg (PPCfnmsub f64:$A, f64:$B, f64:$C)),
2508 (XSMSUBADP $C, $A, $B)>;
2509 def : Pat<(PPCfnmsub f64:$A, f64:$B, (fneg f64:$C)),
2510 (XSNMADDADP $C, $A, $B)>;
2512 def : Pat<(PPCfnmsub v2f64:$A, v2f64:$B, v2f64:$C),
2513 (XVNMSUBADP $C, $A, $B)>;
2514 def : Pat<(fneg (PPCfnmsub v2f64:$A, v2f64:$B, v2f64:$C)),
2515 (XVMSUBADP $C, $A, $B)>;
2516 def : Pat<(PPCfnmsub v2f64:$A, v2f64:$B, (fneg v2f64:$C)),
2517 (XVNMADDADP $C, $A, $B)>;
2519 def : Pat<(PPCfnmsub v4f32:$A, v4f32:$B, v4f32:$C),
2520 (XVNMSUBASP $C, $A, $B)>;
2521 def : Pat<(fneg (PPCfnmsub v4f32:$A, v4f32:$B, v4f32:$C)),
2522 (XVMSUBASP $C, $A, $B)>;
2523 def : Pat<(PPCfnmsub v4f32:$A, v4f32:$B, (fneg v4f32:$C)),
2524 (XVNMADDASP $C, $A, $B)>;
2526 def : Pat<(PPCfsqrt f64:$frA), (XSSQRTDP $frA)>;
2527 def : Pat<(PPCfsqrt v2f64:$frA), (XVSQRTDP $frA)>;
2528 def : Pat<(PPCfsqrt v4f32:$frA), (XVSQRTSP $frA)>;
2530 def : Pat<(v2f64 (bitconvert v4f32:$A)),
2531 (COPY_TO_REGCLASS $A, VSRC)>;
2532 def : Pat<(v2f64 (bitconvert v4i32:$A)),
2533 (COPY_TO_REGCLASS $A, VSRC)>;
2534 def : Pat<(v2f64 (bitconvert v8i16:$A)),
2535 (COPY_TO_REGCLASS $A, VSRC)>;
2536 def : Pat<(v2f64 (bitconvert v16i8:$A)),
2537 (COPY_TO_REGCLASS $A, VSRC)>;
2539 def : Pat<(v4f32 (bitconvert v2f64:$A)),
2540 (COPY_TO_REGCLASS $A, VRRC)>;
2541 def : Pat<(v4i32 (bitconvert v2f64:$A)),
2542 (COPY_TO_REGCLASS $A, VRRC)>;
2543 def : Pat<(v8i16 (bitconvert v2f64:$A)),
2544 (COPY_TO_REGCLASS $A, VRRC)>;
2545 def : Pat<(v16i8 (bitconvert v2f64:$A)),
2546 (COPY_TO_REGCLASS $A, VRRC)>;
2548 def : Pat<(v2i64 (bitconvert v4f32:$A)),
2549 (COPY_TO_REGCLASS $A, VSRC)>;
2550 def : Pat<(v2i64 (bitconvert v4i32:$A)),
2551 (COPY_TO_REGCLASS $A, VSRC)>;
2552 def : Pat<(v2i64 (bitconvert v8i16:$A)),
2553 (COPY_TO_REGCLASS $A, VSRC)>;
2554 def : Pat<(v2i64 (bitconvert v16i8:$A)),
2555 (COPY_TO_REGCLASS $A, VSRC)>;
2557 def : Pat<(v4f32 (bitconvert v2i64:$A)),
2558 (COPY_TO_REGCLASS $A, VRRC)>;
2559 def : Pat<(v4i32 (bitconvert v2i64:$A)),
2560 (COPY_TO_REGCLASS $A, VRRC)>;
2561 def : Pat<(v8i16 (bitconvert v2i64:$A)),
2562 (COPY_TO_REGCLASS $A, VRRC)>;
2563 def : Pat<(v16i8 (bitconvert v2i64:$A)),
2564 (COPY_TO_REGCLASS $A, VRRC)>;
2566 def : Pat<(v2f64 (bitconvert v2i64:$A)),
2567 (COPY_TO_REGCLASS $A, VRRC)>;
2568 def : Pat<(v2i64 (bitconvert v2f64:$A)),
2569 (COPY_TO_REGCLASS $A, VRRC)>;
2571 def : Pat<(v2f64 (bitconvert v1i128:$A)),
2572 (COPY_TO_REGCLASS $A, VRRC)>;
2573 def : Pat<(v1i128 (bitconvert v2f64:$A)),
2574 (COPY_TO_REGCLASS $A, VRRC)>;
2576 def : Pat<(v2i64 (bitconvert f128:$A)),
2577 (COPY_TO_REGCLASS $A, VRRC)>;
2578 def : Pat<(v4i32 (bitconvert f128:$A)),
2579 (COPY_TO_REGCLASS $A, VRRC)>;
2580 def : Pat<(v8i16 (bitconvert f128:$A)),
2581 (COPY_TO_REGCLASS $A, VRRC)>;
2582 def : Pat<(v16i8 (bitconvert f128:$A)),
2583 (COPY_TO_REGCLASS $A, VRRC)>;
2585 def : Pat<(v2f64 (PPCsvec2fp v4i32:$C, 0)),
2586 (v2f64 (XVCVSXWDP (v2i64 (XXMRGHW $C, $C))))>;
2587 def : Pat<(v2f64 (PPCsvec2fp v4i32:$C, 1)),
2588 (v2f64 (XVCVSXWDP (v2i64 (XXMRGLW $C, $C))))>;
2590 def : Pat<(v2f64 (PPCuvec2fp v4i32:$C, 0)),
2591 (v2f64 (XVCVUXWDP (v2i64 (XXMRGHW $C, $C))))>;
2592 def : Pat<(v2f64 (PPCuvec2fp v4i32:$C, 1)),
2593 (v2f64 (XVCVUXWDP (v2i64 (XXMRGLW $C, $C))))>;
2595 def : Pat<(v2f64 (PPCfpexth v4f32:$C, 0)), (XVCVSPDP (XXMRGHW $C, $C))>;
2596 def : Pat<(v2f64 (PPCfpexth v4f32:$C, 1)), (XVCVSPDP (XXMRGLW $C, $C))>;
2599 def : Pat<(v2f64 (PPCxxswapd v2f64:$src)), (XXPERMDI $src, $src, 2)>;
2600 def : Pat<(v2i64 (PPCxxswapd v2i64:$src)), (XXPERMDI $src, $src, 2)>;
2601 def : Pat<(v4f32 (PPCxxswapd v4f32:$src)), (XXPERMDI $src, $src, 2)>;
2602 def : Pat<(v4i32 (PPCxxswapd v4i32:$src)), (XXPERMDI $src, $src, 2)>;
2603 def : Pat<(v2f64 (PPCswapNoChain v2f64:$src)), (XXPERMDI $src, $src, 2)>;
2605 // PPCvecshl XT, XA, XA, 2 can be selected to both XXSLDWI XT,XA,XA,2 and
2606 // XXSWAPD XT,XA (i.e. XXPERMDI XT,XA,XA,2), the later one is more profitable.
2607 def : Pat<(v4i32 (PPCvecshl v4i32:$src, v4i32:$src, 2)),
2608 (XXPERMDI $src, $src, 2)>;
2611 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETLT)),
2612 (SELECT_VSRC (CRANDC $lhs, $rhs), $tval, $fval)>;
2613 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETULT)),
2614 (SELECT_VSRC (CRANDC $rhs, $lhs), $tval, $fval)>;
2615 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETLE)),
2616 (SELECT_VSRC (CRORC $lhs, $rhs), $tval, $fval)>;
2617 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETULE)),
2618 (SELECT_VSRC (CRORC $rhs, $lhs), $tval, $fval)>;
2619 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETEQ)),
2620 (SELECT_VSRC (CREQV $lhs, $rhs), $tval, $fval)>;
2621 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETGE)),
2622 (SELECT_VSRC (CRORC $rhs, $lhs), $tval, $fval)>;
2623 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETUGE)),
2624 (SELECT_VSRC (CRORC $lhs, $rhs), $tval, $fval)>;
2625 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETGT)),
2626 (SELECT_VSRC (CRANDC $rhs, $lhs), $tval, $fval)>;
2627 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETUGT)),
2628 (SELECT_VSRC (CRANDC $lhs, $rhs), $tval, $fval)>;
2629 def : Pat<(v2f64 (selectcc i1:$lhs, i1:$rhs, v2f64:$tval, v2f64:$fval, SETNE)),
2630 (SELECT_VSRC (CRXOR $lhs, $rhs), $tval, $fval)>;
2632 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
2633 (SELECT_VSFRC (CRANDC $lhs, $rhs), $tval, $fval)>;
2634 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
2635 (SELECT_VSFRC (CRANDC $rhs, $lhs), $tval, $fval)>;
2636 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
2637 (SELECT_VSFRC (CRORC $lhs, $rhs), $tval, $fval)>;
2638 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
2639 (SELECT_VSFRC (CRORC $rhs, $lhs), $tval, $fval)>;
2640 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
2641 (SELECT_VSFRC (CREQV $lhs, $rhs), $tval, $fval)>;
2642 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
2643 (SELECT_VSFRC (CRORC $rhs, $lhs), $tval, $fval)>;
2644 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
2645 (SELECT_VSFRC (CRORC $lhs, $rhs), $tval, $fval)>;
2646 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
2647 (SELECT_VSFRC (CRANDC $rhs, $lhs), $tval, $fval)>;
2648 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
2649 (SELECT_VSFRC (CRANDC $lhs, $rhs), $tval, $fval)>;
2650 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
2651 (SELECT_VSFRC (CRXOR $lhs, $rhs), $tval, $fval)>;
2654 def : Pat<(int_ppc_vsx_xvdivsp v4f32:$A, v4f32:$B),
2656 def : Pat<(int_ppc_vsx_xvdivdp v2f64:$A, v2f64:$B),
2659 // Vector test for software divide and sqrt.
2660 def : Pat<(i32 (int_ppc_vsx_xvtdivdp v2f64:$A, v2f64:$B)),
2661 (COPY_TO_REGCLASS (XVTDIVDP $A, $B), GPRC)>;
2662 def : Pat<(i32 (int_ppc_vsx_xvtdivsp v4f32:$A, v4f32:$B)),
2663 (COPY_TO_REGCLASS (XVTDIVSP $A, $B), GPRC)>;
2664 def : Pat<(i32 (int_ppc_vsx_xvtsqrtdp v2f64:$A)),
2665 (COPY_TO_REGCLASS (XVTSQRTDP $A), GPRC)>;
2666 def : Pat<(i32 (int_ppc_vsx_xvtsqrtsp v4f32:$A)),
2667 (COPY_TO_REGCLASS (XVTSQRTSP $A), GPRC)>;
2669 // Reciprocal estimate
2670 def : Pat<(int_ppc_vsx_xvresp v4f32:$A),
2672 def : Pat<(int_ppc_vsx_xvredp v2f64:$A),
2675 // Recip. square root estimate
2676 def : Pat<(int_ppc_vsx_xvrsqrtesp v4f32:$A),
2678 def : Pat<(int_ppc_vsx_xvrsqrtedp v2f64:$A),
2682 def : Pat<(v16i8 (vselect v16i8:$vA, v16i8:$vB, v16i8:$vC)),
2684 (XXSEL (COPY_TO_REGCLASS $vC, VSRC),
2685 (COPY_TO_REGCLASS $vB, VSRC),
2686 (COPY_TO_REGCLASS $vA, VSRC)), VRRC)>;
2687 def : Pat<(v8i16 (vselect v8i16:$vA, v8i16:$vB, v8i16:$vC)),
2689 (XXSEL (COPY_TO_REGCLASS $vC, VSRC),
2690 (COPY_TO_REGCLASS $vB, VSRC),
2691 (COPY_TO_REGCLASS $vA, VSRC)), VRRC)>;
2692 def : Pat<(vselect v4i32:$vA, v4i32:$vB, v4i32:$vC),
2693 (XXSEL $vC, $vB, $vA)>;
2694 def : Pat<(vselect v2i64:$vA, v2i64:$vB, v2i64:$vC),
2695 (XXSEL $vC, $vB, $vA)>;
2696 def : Pat<(vselect v4i32:$vA, v4f32:$vB, v4f32:$vC),
2697 (XXSEL $vC, $vB, $vA)>;
2698 def : Pat<(vselect v2i64:$vA, v2f64:$vB, v2f64:$vC),
2699 (XXSEL $vC, $vB, $vA)>;
2700 def : Pat<(v1i128 (vselect v1i128:$vA, v1i128:$vB, v1i128:$vC)),
2702 (XXSEL (COPY_TO_REGCLASS $vC, VSRC),
2703 (COPY_TO_REGCLASS $vB, VSRC),
2704 (COPY_TO_REGCLASS $vA, VSRC)), VRRC)>;
2706 def : Pat<(v4f32 (any_fmaxnum v4f32:$src1, v4f32:$src2)),
2707 (v4f32 (XVMAXSP $src1, $src2))>;
2708 def : Pat<(v4f32 (any_fminnum v4f32:$src1, v4f32:$src2)),
2709 (v4f32 (XVMINSP $src1, $src2))>;
2710 def : Pat<(v2f64 (any_fmaxnum v2f64:$src1, v2f64:$src2)),
2711 (v2f64 (XVMAXDP $src1, $src2))>;
2712 def : Pat<(v2f64 (any_fminnum v2f64:$src1, v2f64:$src2)),
2713 (v2f64 (XVMINDP $src1, $src2))>;
2716 def : Pat<(f32 (fabs f32:$S)),
2717 (f32 (COPY_TO_REGCLASS (XSABSDP
2718 (COPY_TO_REGCLASS $S, VSFRC)), VSSRC))>;
2721 def : Pat<(f32 (fneg (fabs f32:$S))),
2722 (f32 (COPY_TO_REGCLASS (XSNABSDP
2723 (COPY_TO_REGCLASS $S, VSFRC)), VSSRC))>;
2726 def : Pat<(f32 (fminnum_ieee f32:$A, f32:$B)),
2727 (f32 FpMinMax.F32Min)>;
2728 def : Pat<(f32 (fminnum_ieee (fcanonicalize f32:$A), f32:$B)),
2729 (f32 FpMinMax.F32Min)>;
2730 def : Pat<(f32 (fminnum_ieee f32:$A, (fcanonicalize f32:$B))),
2731 (f32 FpMinMax.F32Min)>;
2732 def : Pat<(f32 (fminnum_ieee (fcanonicalize f32:$A), (fcanonicalize f32:$B))),
2733 (f32 FpMinMax.F32Min)>;
2735 def : Pat<(f32 (fmaxnum_ieee f32:$A, f32:$B)),
2736 (f32 FpMinMax.F32Max)>;
2737 def : Pat<(f32 (fmaxnum_ieee (fcanonicalize f32:$A), f32:$B)),
2738 (f32 FpMinMax.F32Max)>;
2739 def : Pat<(f32 (fmaxnum_ieee f32:$A, (fcanonicalize f32:$B))),
2740 (f32 FpMinMax.F32Max)>;
2741 def : Pat<(f32 (fmaxnum_ieee (fcanonicalize f32:$A), (fcanonicalize f32:$B))),
2742 (f32 FpMinMax.F32Max)>;
2745 def : Pat<(f64 (fminnum_ieee f64:$A, f64:$B)),
2746 (f64 (XSMINDP $A, $B))>;
2747 def : Pat<(f64 (fminnum_ieee (fcanonicalize f64:$A), f64:$B)),
2748 (f64 (XSMINDP $A, $B))>;
2749 def : Pat<(f64 (fminnum_ieee f64:$A, (fcanonicalize f64:$B))),
2750 (f64 (XSMINDP $A, $B))>;
2751 def : Pat<(f64 (fminnum_ieee (fcanonicalize f64:$A), (fcanonicalize f64:$B))),
2752 (f64 (XSMINDP $A, $B))>;
2754 def : Pat<(f64 (fmaxnum_ieee f64:$A, f64:$B)),
2755 (f64 (XSMAXDP $A, $B))>;
2756 def : Pat<(f64 (fmaxnum_ieee (fcanonicalize f64:$A), f64:$B)),
2757 (f64 (XSMAXDP $A, $B))>;
2758 def : Pat<(f64 (fmaxnum_ieee f64:$A, (fcanonicalize f64:$B))),
2759 (f64 (XSMAXDP $A, $B))>;
2760 def : Pat<(f64 (fmaxnum_ieee (fcanonicalize f64:$A), (fcanonicalize f64:$B))),
2761 (f64 (XSMAXDP $A, $B))>;
2763 def : Pat<(int_ppc_vsx_stxvd2x_be v2f64:$rS, ForceXForm:$dst),
2764 (STXVD2X $rS, ForceXForm:$dst)>;
2765 def : Pat<(int_ppc_vsx_stxvw4x_be v4i32:$rS, ForceXForm:$dst),
2766 (STXVW4X $rS, ForceXForm:$dst)>;
2767 def : Pat<(v4i32 (int_ppc_vsx_lxvw4x_be ForceXForm:$src)), (LXVW4X ForceXForm:$src)>;
2768 def : Pat<(v2f64 (int_ppc_vsx_lxvd2x_be ForceXForm:$src)), (LXVD2X ForceXForm:$src)>;
2770 // Rounding for single precision.
2771 def : Pat<(f32 (any_fround f32:$S)),
2772 (f32 (COPY_TO_REGCLASS (XSRDPI
2773 (COPY_TO_REGCLASS $S, VSFRC)), VSSRC))>;
2774 def : Pat<(f32 (fnearbyint f32:$S)),
2775 (f32 (COPY_TO_REGCLASS (XSRDPIC
2776 (COPY_TO_REGCLASS $S, VSFRC)), VSSRC))>;
2777 def : Pat<(f32 (any_ffloor f32:$S)),
2778 (f32 (COPY_TO_REGCLASS (XSRDPIM
2779 (COPY_TO_REGCLASS $S, VSFRC)), VSSRC))>;
2780 def : Pat<(f32 (any_fceil f32:$S)),
2781 (f32 (COPY_TO_REGCLASS (XSRDPIP
2782 (COPY_TO_REGCLASS $S, VSFRC)), VSSRC))>;
2783 def : Pat<(f32 (any_ftrunc f32:$S)),
2784 (f32 (COPY_TO_REGCLASS (XSRDPIZ
2785 (COPY_TO_REGCLASS $S, VSFRC)), VSSRC))>;
2786 def : Pat<(f32 (any_frint f32:$S)),
2787 (f32 (COPY_TO_REGCLASS (XSRDPIC
2788 (COPY_TO_REGCLASS $S, VSFRC)), VSSRC))>;
2789 def : Pat<(v4f32 (any_frint v4f32:$S)), (v4f32 (XVRSPIC $S))>;
2791 // Rounding for double precision.
2792 def : Pat<(f64 (any_frint f64:$S)), (f64 (XSRDPIC $S))>;
2793 def : Pat<(v2f64 (any_frint v2f64:$S)), (v2f64 (XVRDPIC $S))>;
2795 // Materialize a zero-vector of long long
2796 def : Pat<(v2i64 immAllZerosV),
2799 // Build vectors of floating point converted to i32.
2800 def : Pat<(v4i32 (build_vector DblToInt.A, DblToInt.A,
2801 DblToInt.A, DblToInt.A)),
2802 (v4i32 (XXSPLTW (SUBREG_TO_REG (i64 1), (XSCVDPSXWS $A), sub_64), 1))>;
2803 def : Pat<(v4i32 (build_vector DblToUInt.A, DblToUInt.A,
2804 DblToUInt.A, DblToUInt.A)),
2805 (v4i32 (XXSPLTW (SUBREG_TO_REG (i64 1), (XSCVDPUXWS $A), sub_64), 1))>;
2806 def : Pat<(v2i64 (build_vector DblToLong.A, DblToLong.A)),
2807 (v2i64 (XXPERMDI (SUBREG_TO_REG (i64 1), (XSCVDPSXDS $A), sub_64),
2808 (SUBREG_TO_REG (i64 1), (XSCVDPSXDS $A), sub_64), 0))>;
2809 def : Pat<(v2i64 (build_vector DblToULong.A, DblToULong.A)),
2810 (v2i64 (XXPERMDI (SUBREG_TO_REG (i64 1), (XSCVDPUXDS $A), sub_64),
2811 (SUBREG_TO_REG (i64 1), (XSCVDPUXDS $A), sub_64), 0))>;
2812 defm : ScalToVecWPermute<
2813 v4i32, FltToIntLoad.A,
2814 (XXSPLTW (SUBREG_TO_REG (i64 1), (XSCVDPSXWSs (XFLOADf32 ForceXForm:$A)), sub_64), 1),
2815 (SUBREG_TO_REG (i64 1), (XSCVDPSXWSs (XFLOADf32 ForceXForm:$A)), sub_64)>;
2816 defm : ScalToVecWPermute<
2817 v4i32, FltToUIntLoad.A,
2818 (XXSPLTW (SUBREG_TO_REG (i64 1), (XSCVDPUXWSs (XFLOADf32 ForceXForm:$A)), sub_64), 1),
2819 (SUBREG_TO_REG (i64 1), (XSCVDPUXWSs (XFLOADf32 ForceXForm:$A)), sub_64)>;
2820 def : Pat<(v4f32 (build_vector (f32 (fpround f64:$A)), (f32 (fpround f64:$A)),
2821 (f32 (fpround f64:$A)), (f32 (fpround f64:$A)))),
2822 (v4f32 (XXSPLTW (SUBREG_TO_REG (i64 1), (XSCVDPSP f64:$A), sub_64), 0))>;
2824 def : Pat<(v4f32 (build_vector f32:$A, f32:$A, f32:$A, f32:$A)),
2825 (v4f32 (XXSPLTW (v4f32 (XSCVDPSPN $A)), 0))>;
2826 def : Pat<(v2f64 (PPCldsplat ForceXForm:$A)),
2827 (v2f64 (LXVDSX ForceXForm:$A))>;
2828 def : Pat<(v2i64 (PPCldsplat ForceXForm:$A)),
2829 (v2i64 (LXVDSX ForceXForm:$A))>;
2831 // Build vectors of floating point converted to i64.
2832 def : Pat<(v2i64 (build_vector FltToLong.A, FltToLong.A)),
2834 (COPY_TO_REGCLASS (XSCVDPSXDSs $A), VSFRC), 0))>;
2835 def : Pat<(v2i64 (build_vector FltToULong.A, FltToULong.A)),
2837 (COPY_TO_REGCLASS (XSCVDPUXDSs $A), VSFRC), 0))>;
2838 defm : ScalToVecWPermute<
2839 v2i64, DblToLongLoad.A,
2840 (XVCVDPSXDS (LXVDSX ForceXForm:$A)), (XVCVDPSXDS (LXVDSX ForceXForm:$A))>;
2841 defm : ScalToVecWPermute<
2842 v2i64, DblToULongLoad.A,
2843 (XVCVDPUXDS (LXVDSX ForceXForm:$A)), (XVCVDPUXDS (LXVDSX ForceXForm:$A))>;
2845 // Doubleword vector predicate comparisons without Power8.
2846 let AddedComplexity = 0 in {
2847 def : Pat<(v2i64 (PPCvcmp_rec v2i64:$vA, v2i64:$vB, 967)),
2848 (VCMPGTUB_rec DblwdCmp.MRGSGT, (v2i64 (XXLXORz)))>;
2849 def : Pat<(v2i64 (PPCvcmp_rec v2i64:$vA, v2i64:$vB, 711)),
2850 (VCMPGTUB_rec DblwdCmp.MRGUGT, (v2i64 (XXLXORz)))>;
2851 def : Pat<(v2i64 (PPCvcmp_rec v2i64:$vA, v2i64:$vB, 199)),
2852 (VCMPGTUB_rec DblwdCmp.MRGEQ, (v2i64 (XXLXORz)))>;
2853 } // AddedComplexity = 0
2855 // XL Compat builtins.
2856 def : Pat<(int_ppc_fmsub f64:$A, f64:$B, f64:$C), (XSMSUBMDP $A, $B, $C)>;
2857 def : Pat<(int_ppc_fnmsub f64:$A, f64:$B, f64:$C), (XSNMSUBMDP $A, $B, $C)>;
2858 def : Pat<(int_ppc_fnmadd f64:$A, f64:$B, f64:$C), (XSNMADDMDP $A, $B, $C)>;
2859 def : Pat<(int_ppc_fre f64:$A), (XSREDP $A)>;
2860 def : Pat<(int_ppc_frsqrte vsfrc:$XB), (XSRSQRTEDP $XB)>;
2863 // Any big endian VSX subtarget.
2864 let Predicates = [HasVSX, IsBigEndian] in {
2865 def : Pat<(v2f64 (scalar_to_vector f64:$A)),
2866 (v2f64 (SUBREG_TO_REG (i64 1), $A, sub_64))>;
2868 def : Pat<(f64 (extractelt v2f64:$S, 0)),
2869 (f64 (EXTRACT_SUBREG $S, sub_64))>;
2870 def : Pat<(f64 (extractelt v2f64:$S, 1)),
2871 (f64 (EXTRACT_SUBREG (XXPERMDI $S, $S, 2), sub_64))>;
2872 def : Pat<(f64 (PPCfcfid (PPCmtvsra (i64 (vector_extract v2i64:$S, 0))))),
2873 (f64 (XSCVSXDDP (COPY_TO_REGCLASS $S, VSFRC)))>;
2874 def : Pat<(f64 (PPCfcfid (PPCmtvsra (i64 (vector_extract v2i64:$S, 1))))),
2875 (f64 (XSCVSXDDP (COPY_TO_REGCLASS (XXPERMDI $S, $S, 2), VSFRC)))>;
2876 def : Pat<(f64 (PPCfcfidu (PPCmtvsra (i64 (vector_extract v2i64:$S, 0))))),
2877 (f64 (XSCVUXDDP (COPY_TO_REGCLASS $S, VSFRC)))>;
2878 def : Pat<(f64 (PPCfcfidu (PPCmtvsra (i64 (vector_extract v2i64:$S, 1))))),
2879 (f64 (XSCVUXDDP (COPY_TO_REGCLASS (XXPERMDI $S, $S, 2), VSFRC)))>;
2881 def : Pat<(f64 (vector_extract v2f64:$S, i64:$Idx)),
2882 (f64 VectorExtractions.BE_VARIABLE_DOUBLE)>;
2884 def : Pat<(v2f64 (build_vector f64:$A, f64:$B)),
2886 (SUBREG_TO_REG (i64 1), $A, sub_64),
2887 (SUBREG_TO_REG (i64 1), $B, sub_64), 0))>;
2888 // Using VMRGEW to assemble the final vector would be a lower latency
2889 // solution. However, we choose to go with the slightly higher latency
2890 // XXPERMDI for 2 reasons:
2891 // 1. This is likely to occur in unrolled loops where regpressure is high,
2892 // so we want to use the latter as it has access to all 64 VSX registers.
2893 // 2. Using Altivec instructions in this sequence would likely cause the
2894 // allocation of Altivec registers even for the loads which in turn would
2895 // force the use of LXSIWZX for the loads, adding a cycle of latency to
2896 // each of the loads which would otherwise be able to use LFIWZX.
2897 def : Pat<(v4f32 (build_vector LoadFP.A, LoadFP.B, LoadFP.C, LoadFP.D)),
2898 (v4f32 (XXPERMDI (XXMRGHW MrgFP.LD32A, MrgFP.LD32B),
2899 (XXMRGHW MrgFP.LD32C, MrgFP.LD32D), 3))>;
2900 def : Pat<(v4f32 (build_vector f32:$A, f32:$B, f32:$C, f32:$D)),
2901 (VMRGEW MrgFP.AC, MrgFP.BD)>;
2902 def : Pat<(v4f32 (build_vector DblToFlt.A0, DblToFlt.A1,
2903 DblToFlt.B0, DblToFlt.B1)),
2904 (v4f32 (VMRGEW MrgFP.ABhToFlt, MrgFP.ABlToFlt))>;
2906 // Convert 4 doubles to a vector of ints.
2907 def : Pat<(v4i32 (build_vector DblToInt.A, DblToInt.B,
2908 DblToInt.C, DblToInt.D)),
2909 (v4i32 (VMRGEW MrgWords.CVACS, MrgWords.CVBDS))>;
2910 def : Pat<(v4i32 (build_vector DblToUInt.A, DblToUInt.B,
2911 DblToUInt.C, DblToUInt.D)),
2912 (v4i32 (VMRGEW MrgWords.CVACU, MrgWords.CVBDU))>;
2913 def : Pat<(v4i32 (build_vector ExtDbl.A0S, ExtDbl.A1S,
2914 ExtDbl.B0S, ExtDbl.B1S)),
2915 (v4i32 (VMRGEW MrgWords.CVA0B0S, MrgWords.CVA1B1S))>;
2916 def : Pat<(v4i32 (build_vector ExtDbl.A0U, ExtDbl.A1U,
2917 ExtDbl.B0U, ExtDbl.B1U)),
2918 (v4i32 (VMRGEW MrgWords.CVA0B0U, MrgWords.CVA1B1U))>;
2919 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 0))),
2920 (f64 (fpextend (extractelt v4f32:$A, 1))))),
2921 (v2f64 (XVCVSPDP (XXMRGHW $A, $A)))>;
2922 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 1))),
2923 (f64 (fpextend (extractelt v4f32:$A, 0))))),
2924 (v2f64 (XXPERMDI (XVCVSPDP (XXMRGHW $A, $A)),
2925 (XVCVSPDP (XXMRGHW $A, $A)), 2))>;
2926 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 0))),
2927 (f64 (fpextend (extractelt v4f32:$A, 2))))),
2928 (v2f64 (XVCVSPDP $A))>;
2929 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 1))),
2930 (f64 (fpextend (extractelt v4f32:$A, 3))))),
2931 (v2f64 (XVCVSPDP (XXSLDWI $A, $A, 3)))>;
2932 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 2))),
2933 (f64 (fpextend (extractelt v4f32:$A, 3))))),
2934 (v2f64 (XVCVSPDP (XXMRGLW $A, $A)))>;
2935 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 3))),
2936 (f64 (fpextend (extractelt v4f32:$A, 2))))),
2937 (v2f64 (XXPERMDI (XVCVSPDP (XXMRGLW $A, $A)),
2938 (XVCVSPDP (XXMRGLW $A, $A)), 2))>;
2939 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 0))),
2940 (f64 (fpextend (extractelt v4f32:$B, 0))))),
2941 (v2f64 (XVCVSPDP (XXPERMDI $A, $B, 0)))>;
2942 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 3))),
2943 (f64 (fpextend (extractelt v4f32:$B, 3))))),
2944 (v2f64 (XVCVSPDP (XXSLDWI (XXPERMDI $A, $B, 3),
2945 (XXPERMDI $A, $B, 3), 1)))>;
2946 def : Pat<(v2i64 (fp_to_sint
2947 (build_vector (f64 (fpextend (extractelt v4f32:$A, 0))),
2948 (f64 (fpextend (extractelt v4f32:$A, 2)))))),
2949 (v2i64 (XVCVSPSXDS $A))>;
2950 def : Pat<(v2i64 (fp_to_uint
2951 (build_vector (f64 (fpextend (extractelt v4f32:$A, 0))),
2952 (f64 (fpextend (extractelt v4f32:$A, 2)))))),
2953 (v2i64 (XVCVSPUXDS $A))>;
2954 def : Pat<(v2i64 (fp_to_sint
2955 (build_vector (f64 (fpextend (extractelt v4f32:$A, 1))),
2956 (f64 (fpextend (extractelt v4f32:$A, 3)))))),
2957 (v2i64 (XVCVSPSXDS (XXSLDWI $A, $A, 1)))>;
2958 def : Pat<(v2i64 (fp_to_uint
2959 (build_vector (f64 (fpextend (extractelt v4f32:$A, 1))),
2960 (f64 (fpextend (extractelt v4f32:$A, 3)))))),
2961 (v2i64 (XVCVSPUXDS (XXSLDWI $A, $A, 1)))>;
2962 def : Pat<WToDPExtractConv.BV02S,
2963 (v2f64 (XVCVSXWDP $A))>;
2964 def : Pat<WToDPExtractConv.BV13S,
2965 (v2f64 (XVCVSXWDP (XXSLDWI $A, $A, 1)))>;
2966 def : Pat<WToDPExtractConv.BV02U,
2967 (v2f64 (XVCVUXWDP $A))>;
2968 def : Pat<WToDPExtractConv.BV13U,
2969 (v2f64 (XVCVUXWDP (XXSLDWI $A, $A, 1)))>;
2970 def : Pat<(v2f64 (insertelt v2f64:$A, f64:$B, 0)),
2971 (v2f64 (XXPERMDI (SUBREG_TO_REG (i64 1), $B, sub_64), $A, 1))>;
2972 def : Pat<(v2f64 (insertelt v2f64:$A, f64:$B, 1)),
2973 (v2f64 (XXPERMDI $A, (SUBREG_TO_REG (i64 1), $B, sub_64), 0))>;
2974 } // HasVSX, IsBigEndian
2976 // Any little endian VSX subtarget.
2977 let Predicates = [HasVSX, IsLittleEndian] in {
2978 defm : ScalToVecWPermute<v2f64, (f64 f64:$A),
2979 (XXPERMDI (SUBREG_TO_REG (i64 1), $A, sub_64),
2980 (SUBREG_TO_REG (i64 1), $A, sub_64), 0),
2981 (SUBREG_TO_REG (i64 1), $A, sub_64)>;
2983 def : Pat<(f64 (extractelt (v2f64 (bitconvert (v16i8
2984 (PPCvperm v16i8:$A, v16i8:$B, v16i8:$C)))), 0)),
2985 (f64 (EXTRACT_SUBREG (VPERM $B, $A, $C), sub_64))>;
2986 def : Pat<(f64 (extractelt v2f64:$S, 0)),
2987 (f64 (EXTRACT_SUBREG (XXPERMDI $S, $S, 2), sub_64))>;
2988 def : Pat<(f64 (extractelt v2f64:$S, 1)),
2989 (f64 (EXTRACT_SUBREG $S, sub_64))>;
2991 def : Pat<(v2f64 (PPCld_vec_be ForceXForm:$src)), (LXVD2X ForceXForm:$src)>;
2992 def : Pat<(PPCst_vec_be v2f64:$rS, ForceXForm:$dst), (STXVD2X $rS, ForceXForm:$dst)>;
2993 def : Pat<(v4f32 (PPCld_vec_be ForceXForm:$src)), (LXVW4X ForceXForm:$src)>;
2994 def : Pat<(PPCst_vec_be v4f32:$rS, ForceXForm:$dst), (STXVW4X $rS, ForceXForm:$dst)>;
2995 def : Pat<(v2i64 (PPCld_vec_be ForceXForm:$src)), (LXVD2X ForceXForm:$src)>;
2996 def : Pat<(PPCst_vec_be v2i64:$rS, ForceXForm:$dst), (STXVD2X $rS, ForceXForm:$dst)>;
2997 def : Pat<(v4i32 (PPCld_vec_be ForceXForm:$src)), (LXVW4X ForceXForm:$src)>;
2998 def : Pat<(PPCst_vec_be v4i32:$rS, ForceXForm:$dst), (STXVW4X $rS, ForceXForm:$dst)>;
2999 def : Pat<(f64 (PPCfcfid (PPCmtvsra (i64 (vector_extract v2i64:$S, 0))))),
3000 (f64 (XSCVSXDDP (COPY_TO_REGCLASS (XXPERMDI $S, $S, 2), VSFRC)))>;
3001 def : Pat<(f64 (PPCfcfid (PPCmtvsra (i64 (vector_extract v2i64:$S, 1))))),
3002 (f64 (XSCVSXDDP (COPY_TO_REGCLASS (f64 (COPY_TO_REGCLASS $S, VSRC)), VSFRC)))>;
3003 def : Pat<(f64 (PPCfcfidu (PPCmtvsra (i64 (vector_extract v2i64:$S, 0))))),
3004 (f64 (XSCVUXDDP (COPY_TO_REGCLASS (XXPERMDI $S, $S, 2), VSFRC)))>;
3005 def : Pat<(f64 (PPCfcfidu (PPCmtvsra (i64 (vector_extract v2i64:$S, 1))))),
3006 (f64 (XSCVUXDDP (COPY_TO_REGCLASS (f64 (COPY_TO_REGCLASS $S, VSRC)), VSFRC)))>;
3008 def : Pat<(f64 (vector_extract v2f64:$S, i64:$Idx)),
3009 (f64 VectorExtractions.LE_VARIABLE_DOUBLE)>;
3011 // Little endian, available on all targets with VSX
3012 def : Pat<(v2f64 (build_vector f64:$A, f64:$B)),
3014 (SUBREG_TO_REG (i64 1), $B, sub_64),
3015 (SUBREG_TO_REG (i64 1), $A, sub_64), 0))>;
3016 // Using VMRGEW to assemble the final vector would be a lower latency
3017 // solution. However, we choose to go with the slightly higher latency
3018 // XXPERMDI for 2 reasons:
3019 // 1. This is likely to occur in unrolled loops where regpressure is high,
3020 // so we want to use the latter as it has access to all 64 VSX registers.
3021 // 2. Using Altivec instructions in this sequence would likely cause the
3022 // allocation of Altivec registers even for the loads which in turn would
3023 // force the use of LXSIWZX for the loads, adding a cycle of latency to
3024 // each of the loads which would otherwise be able to use LFIWZX.
3025 def : Pat<(v4f32 (build_vector LoadFP.A, LoadFP.B, LoadFP.C, LoadFP.D)),
3026 (v4f32 (XXPERMDI (XXMRGHW MrgFP.LD32D, MrgFP.LD32C),
3027 (XXMRGHW MrgFP.LD32B, MrgFP.LD32A), 3))>;
3028 def : Pat<(v4f32 (build_vector f32:$D, f32:$C, f32:$B, f32:$A)),
3029 (VMRGEW MrgFP.AC, MrgFP.BD)>;
3030 def : Pat<(v4f32 (build_vector DblToFlt.A0, DblToFlt.A1,
3031 DblToFlt.B0, DblToFlt.B1)),
3032 (v4f32 (VMRGEW MrgFP.BAhToFlt, MrgFP.BAlToFlt))>;
3034 // Convert 4 doubles to a vector of ints.
3035 def : Pat<(v4i32 (build_vector DblToInt.A, DblToInt.B,
3036 DblToInt.C, DblToInt.D)),
3037 (v4i32 (VMRGEW MrgWords.CVDBS, MrgWords.CVCAS))>;
3038 def : Pat<(v4i32 (build_vector DblToUInt.A, DblToUInt.B,
3039 DblToUInt.C, DblToUInt.D)),
3040 (v4i32 (VMRGEW MrgWords.CVDBU, MrgWords.CVCAU))>;
3041 def : Pat<(v4i32 (build_vector ExtDbl.A0S, ExtDbl.A1S,
3042 ExtDbl.B0S, ExtDbl.B1S)),
3043 (v4i32 (VMRGEW MrgWords.CVB1A1S, MrgWords.CVB0A0S))>;
3044 def : Pat<(v4i32 (build_vector ExtDbl.A0U, ExtDbl.A1U,
3045 ExtDbl.B0U, ExtDbl.B1U)),
3046 (v4i32 (VMRGEW MrgWords.CVB1A1U, MrgWords.CVB0A0U))>;
3047 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 0))),
3048 (f64 (fpextend (extractelt v4f32:$A, 1))))),
3049 (v2f64 (XVCVSPDP (XXMRGLW $A, $A)))>;
3050 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 1))),
3051 (f64 (fpextend (extractelt v4f32:$A, 0))))),
3052 (v2f64 (XXPERMDI (XVCVSPDP (XXMRGLW $A, $A)),
3053 (XVCVSPDP (XXMRGLW $A, $A)), 2))>;
3054 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 0))),
3055 (f64 (fpextend (extractelt v4f32:$A, 2))))),
3056 (v2f64 (XVCVSPDP (XXSLDWI $A, $A, 1)))>;
3057 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 1))),
3058 (f64 (fpextend (extractelt v4f32:$A, 3))))),
3059 (v2f64 (XVCVSPDP $A))>;
3060 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 2))),
3061 (f64 (fpextend (extractelt v4f32:$A, 3))))),
3062 (v2f64 (XVCVSPDP (XXMRGHW $A, $A)))>;
3063 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 3))),
3064 (f64 (fpextend (extractelt v4f32:$A, 2))))),
3065 (v2f64 (XXPERMDI (XVCVSPDP (XXMRGHW $A, $A)),
3066 (XVCVSPDP (XXMRGHW $A, $A)), 2))>;
3067 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 0))),
3068 (f64 (fpextend (extractelt v4f32:$B, 0))))),
3069 (v2f64 (XVCVSPDP (XXSLDWI (XXPERMDI $B, $A, 3),
3070 (XXPERMDI $B, $A, 3), 1)))>;
3071 def : Pat<(v2f64 (build_vector (f64 (fpextend (extractelt v4f32:$A, 3))),
3072 (f64 (fpextend (extractelt v4f32:$B, 3))))),
3073 (v2f64 (XVCVSPDP (XXPERMDI $B, $A, 0)))>;
3074 def : Pat<(v2i64 (fp_to_sint
3075 (build_vector (f64 (fpextend (extractelt v4f32:$A, 1))),
3076 (f64 (fpextend (extractelt v4f32:$A, 3)))))),
3077 (v2i64 (XVCVSPSXDS $A))>;
3078 def : Pat<(v2i64 (fp_to_uint
3079 (build_vector (f64 (fpextend (extractelt v4f32:$A, 1))),
3080 (f64 (fpextend (extractelt v4f32:$A, 3)))))),
3081 (v2i64 (XVCVSPUXDS $A))>;
3082 def : Pat<(v2i64 (fp_to_sint
3083 (build_vector (f64 (fpextend (extractelt v4f32:$A, 0))),
3084 (f64 (fpextend (extractelt v4f32:$A, 2)))))),
3085 (v2i64 (XVCVSPSXDS (XXSLDWI $A, $A, 1)))>;
3086 def : Pat<(v2i64 (fp_to_uint
3087 (build_vector (f64 (fpextend (extractelt v4f32:$A, 0))),
3088 (f64 (fpextend (extractelt v4f32:$A, 2)))))),
3089 (v2i64 (XVCVSPUXDS (XXSLDWI $A, $A, 1)))>;
3090 def : Pat<WToDPExtractConv.BV02S,
3091 (v2f64 (XVCVSXWDP (XXSLDWI $A, $A, 1)))>;
3092 def : Pat<WToDPExtractConv.BV13S,
3093 (v2f64 (XVCVSXWDP $A))>;
3094 def : Pat<WToDPExtractConv.BV02U,
3095 (v2f64 (XVCVUXWDP (XXSLDWI $A, $A, 1)))>;
3096 def : Pat<WToDPExtractConv.BV13U,
3097 (v2f64 (XVCVUXWDP $A))>;
3098 def : Pat<(v2f64 (insertelt v2f64:$A, f64:$B, 0)),
3099 (v2f64 (XXPERMDI $A, (SUBREG_TO_REG (i64 1), $B, sub_64), 0))>;
3100 def : Pat<(v2f64 (insertelt v2f64:$A, f64:$B, 1)),
3101 (v2f64 (XXPERMDI (SUBREG_TO_REG (i64 1), $B, sub_64), $A, 1))>;
3102 } // HasVSX, IsLittleEndian
3104 // Any pre-Power9 VSX subtarget.
3105 let Predicates = [HasVSX, NoP9Vector] in {
3106 def : Pat<(PPCstore_scal_int_from_vsr
3107 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), ForceXForm:$dst, 8),
3108 (STXSDX (XSCVDPSXDS f64:$src), ForceXForm:$dst)>;
3109 def : Pat<(PPCstore_scal_int_from_vsr
3110 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), ForceXForm:$dst, 8),
3111 (STXSDX (XSCVDPUXDS f64:$src), ForceXForm:$dst)>;
3113 // Load-and-splat with fp-to-int conversion (using X-Form VSX/FP loads).
3114 defm : ScalToVecWPermute<
3115 v4i32, DblToIntLoad.A,
3116 (XXSPLTW (SUBREG_TO_REG (i64 1), (XSCVDPSXWS (XFLOADf64 ForceXForm:$A)), sub_64), 1),
3117 (SUBREG_TO_REG (i64 1), (XSCVDPSXWS (XFLOADf64 ForceXForm:$A)), sub_64)>;
3118 defm : ScalToVecWPermute<
3119 v4i32, DblToUIntLoad.A,
3120 (XXSPLTW (SUBREG_TO_REG (i64 1), (XSCVDPUXWS (XFLOADf64 ForceXForm:$A)), sub_64), 1),
3121 (SUBREG_TO_REG (i64 1), (XSCVDPUXWS (XFLOADf64 ForceXForm:$A)), sub_64)>;
3122 defm : ScalToVecWPermute<
3123 v2i64, FltToLongLoad.A,
3124 (XXPERMDIs (XSCVDPSXDS (COPY_TO_REGCLASS (XFLOADf32 ForceXForm:$A), VSFRC)), 0),
3125 (SUBREG_TO_REG (i64 1), (XSCVDPSXDS (COPY_TO_REGCLASS (XFLOADf32 ForceXForm:$A),
3127 defm : ScalToVecWPermute<
3128 v2i64, FltToULongLoad.A,
3129 (XXPERMDIs (XSCVDPUXDS (COPY_TO_REGCLASS (XFLOADf32 ForceXForm:$A), VSFRC)), 0),
3130 (SUBREG_TO_REG (i64 1), (XSCVDPUXDS (COPY_TO_REGCLASS (XFLOADf32 ForceXForm:$A),
3132 } // HasVSX, NoP9Vector
3134 // Any little endian pre-Power9 VSX subtarget.
3135 let Predicates = [HasVSX, NoP9Vector, IsLittleEndian] in {
3136 // Load-and-splat using only X-Form VSX loads.
3137 defm : ScalToVecWPermute<
3138 v2i64, (i64 (load ForceXForm:$src)),
3139 (XXPERMDIs (XFLOADf64 ForceXForm:$src), 2),
3140 (SUBREG_TO_REG (i64 1), (XFLOADf64 ForceXForm:$src), sub_64)>;
3141 defm : ScalToVecWPermute<
3142 v2f64, (f64 (load ForceXForm:$src)),
3143 (XXPERMDIs (XFLOADf64 ForceXForm:$src), 2),
3144 (SUBREG_TO_REG (i64 1), (XFLOADf64 ForceXForm:$src), sub_64)>;
3145 } // HasVSX, NoP9Vector, IsLittleEndian
3147 let Predicates = [HasVSX, NoP9Vector, IsBigEndian] in {
3148 def : Pat<(v2f64 (int_ppc_vsx_lxvd2x ForceXForm:$src)),
3149 (LXVD2X ForceXForm:$src)>;
3150 def : Pat<(int_ppc_vsx_stxvd2x v2f64:$rS, ForceXForm:$dst),
3151 (STXVD2X $rS, ForceXForm:$dst)>;
3152 } // HasVSX, NoP9Vector, IsBigEndian
3154 // Any VSX subtarget that only has loads and stores that load in big endian
3155 // order regardless of endianness. This is really pre-Power9 subtargets.
3156 let Predicates = [HasVSX, HasOnlySwappingMemOps] in {
3157 def : Pat<(v2f64 (PPClxvd2x ForceXForm:$src)), (LXVD2X ForceXForm:$src)>;
3160 def : Pat<(PPCstxvd2x v2f64:$rS, ForceXForm:$dst), (STXVD2X $rS, ForceXForm:$dst)>;
3161 } // HasVSX, HasOnlySwappingMemOps
3163 // Big endian VSX subtarget that only has loads and stores that always
3164 // load in big endian order. Really big endian pre-Power9 subtargets.
3165 let Predicates = [HasVSX, HasOnlySwappingMemOps, IsBigEndian] in {
3166 def : Pat<(v2f64 (load ForceXForm:$src)), (LXVD2X ForceXForm:$src)>;
3167 def : Pat<(v2i64 (load ForceXForm:$src)), (LXVD2X ForceXForm:$src)>;
3168 def : Pat<(v4i32 (load ForceXForm:$src)), (LXVW4X ForceXForm:$src)>;
3169 def : Pat<(v4i32 (int_ppc_vsx_lxvw4x ForceXForm:$src)), (LXVW4X ForceXForm:$src)>;
3170 def : Pat<(store v2f64:$rS, ForceXForm:$dst), (STXVD2X $rS, ForceXForm:$dst)>;
3171 def : Pat<(store v2i64:$rS, ForceXForm:$dst), (STXVD2X $rS, ForceXForm:$dst)>;
3172 def : Pat<(store v4i32:$XT, ForceXForm:$dst), (STXVW4X $XT, ForceXForm:$dst)>;
3173 def : Pat<(int_ppc_vsx_stxvw4x v4i32:$rS, ForceXForm:$dst),
3174 (STXVW4X $rS, ForceXForm:$dst)>;
3175 def : Pat<(v2i64 (scalar_to_vector (i64 (load ForceXForm:$src)))),
3176 (SUBREG_TO_REG (i64 1), (XFLOADf64 ForceXForm:$src), sub_64)>;
3177 } // HasVSX, HasOnlySwappingMemOps, IsBigEndian
3179 // Any Power8 VSX subtarget.
3180 let Predicates = [HasVSX, HasP8Vector] in {
3181 def : Pat<(int_ppc_vsx_xxleqv v4i32:$A, v4i32:$B),
3183 def : Pat<(f64 (extloadf32 XForm:$src)),
3184 (COPY_TO_REGCLASS (XFLOADf32 XForm:$src), VSFRC)>;
3185 def : Pat<(f32 (fpround (f64 (extloadf32 ForceXForm:$src)))),
3186 (f32 (XFLOADf32 ForceXForm:$src))>;
3187 def : Pat<(f64 (any_fpextend f32:$src)),
3188 (COPY_TO_REGCLASS $src, VSFRC)>;
3190 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
3191 (SELECT_VSSRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3192 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
3193 (SELECT_VSSRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3194 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
3195 (SELECT_VSSRC (CRORC $lhs, $rhs), $tval, $fval)>;
3196 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
3197 (SELECT_VSSRC (CRORC $rhs, $lhs), $tval, $fval)>;
3198 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
3199 (SELECT_VSSRC (CREQV $lhs, $rhs), $tval, $fval)>;
3200 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
3201 (SELECT_VSSRC (CRORC $rhs, $lhs), $tval, $fval)>;
3202 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
3203 (SELECT_VSSRC (CRORC $lhs, $rhs), $tval, $fval)>;
3204 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
3205 (SELECT_VSSRC (CRANDC $rhs, $lhs), $tval, $fval)>;
3206 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
3207 (SELECT_VSSRC (CRANDC $lhs, $rhs), $tval, $fval)>;
3208 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
3209 (SELECT_VSSRC (CRXOR $lhs, $rhs), $tval, $fval)>;
3211 // Additional fnmsub pattern for PPC specific ISD opcode
3212 def : Pat<(PPCfnmsub f32:$A, f32:$B, f32:$C),
3213 (XSNMSUBASP $C, $A, $B)>;
3214 def : Pat<(fneg (PPCfnmsub f32:$A, f32:$B, f32:$C)),
3215 (XSMSUBASP $C, $A, $B)>;
3216 def : Pat<(PPCfnmsub f32:$A, f32:$B, (fneg f32:$C)),
3217 (XSNMADDASP $C, $A, $B)>;
3220 // Although XSNEGDP is available in P7, we want to select it starting from P8,
3221 // so that FNMSUBS can be selected for fneg-fmsub pattern on P7. (VSX version,
3222 // XSNMSUBASP, is available since P8)
3223 def : Pat<(f32 (fneg f32:$S)),
3224 (f32 (COPY_TO_REGCLASS (XSNEGDP
3225 (COPY_TO_REGCLASS $S, VSFRC)), VSSRC))>;
3227 // Instructions for converting float to i32 feeding a store.
3228 def : Pat<(PPCstore_scal_int_from_vsr
3229 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), ForceXForm:$dst, 4),
3230 (STIWX (XSCVDPSXWS f64:$src), ForceXForm:$dst)>;
3231 def : Pat<(PPCstore_scal_int_from_vsr
3232 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), ForceXForm:$dst, 4),
3233 (STIWX (XSCVDPUXWS f64:$src), ForceXForm:$dst)>;
3235 def : Pat<(v2i64 (smax v2i64:$src1, v2i64:$src2)),
3236 (v2i64 (VMAXSD (COPY_TO_REGCLASS $src1, VRRC),
3237 (COPY_TO_REGCLASS $src2, VRRC)))>;
3238 def : Pat<(v2i64 (umax v2i64:$src1, v2i64:$src2)),
3239 (v2i64 (VMAXUD (COPY_TO_REGCLASS $src1, VRRC),
3240 (COPY_TO_REGCLASS $src2, VRRC)))>;
3241 def : Pat<(v2i64 (smin v2i64:$src1, v2i64:$src2)),
3242 (v2i64 (VMINSD (COPY_TO_REGCLASS $src1, VRRC),
3243 (COPY_TO_REGCLASS $src2, VRRC)))>;
3244 def : Pat<(v2i64 (umin v2i64:$src1, v2i64:$src2)),
3245 (v2i64 (VMINUD (COPY_TO_REGCLASS $src1, VRRC),
3246 (COPY_TO_REGCLASS $src2, VRRC)))>;
3248 def : Pat<(v1i128 (bitconvert (v16i8 immAllOnesV))),
3249 (v1i128 (COPY_TO_REGCLASS(XXLEQVOnes), VSRC))>;
3250 def : Pat<(v2i64 (bitconvert (v16i8 immAllOnesV))),
3251 (v2i64 (COPY_TO_REGCLASS(XXLEQVOnes), VSRC))>;
3252 def : Pat<(v8i16 (bitconvert (v16i8 immAllOnesV))),
3253 (v8i16 (COPY_TO_REGCLASS(XXLEQVOnes), VSRC))>;
3254 def : Pat<(v16i8 (bitconvert (v16i8 immAllOnesV))),
3255 (v16i8 (COPY_TO_REGCLASS(XXLEQVOnes), VSRC))>;
3257 // XL Compat builtins.
3258 def : Pat<(int_ppc_fmsubs f32:$A, f32:$B, f32:$C), (XSMSUBMSP $A, $B, $C)>;
3259 def : Pat<(int_ppc_fnmsubs f32:$A, f32:$B, f32:$C), (XSNMSUBMSP $A, $B, $C)>;
3260 def : Pat<(int_ppc_fnmadds f32:$A, f32:$B, f32:$C), (XSNMADDMSP $A, $B, $C)>;
3261 def : Pat<(int_ppc_fres f32:$A), (XSRESP $A)>;
3262 def : Pat<(i32 (int_ppc_extract_exp f64:$A)),
3263 (EXTRACT_SUBREG (XSXEXPDP (COPY_TO_REGCLASS $A, VSFRC)), sub_32)>;
3264 def : Pat<(int_ppc_extract_sig f64:$A),
3265 (XSXSIGDP (COPY_TO_REGCLASS $A, VSFRC))>;
3266 def : Pat<(f64 (int_ppc_insert_exp f64:$A, i64:$B)),
3267 (COPY_TO_REGCLASS (XSIEXPDP (COPY_TO_REGCLASS $A, G8RC), $B), F8RC)>;
3269 def : Pat<(int_ppc_stfiw ForceXForm:$dst, f64:$XT),
3270 (STXSIWX f64:$XT, ForceXForm:$dst)>;
3271 def : Pat<(int_ppc_frsqrtes vssrc:$XB), (XSRSQRTESP $XB)>;
3272 } // HasVSX, HasP8Vector
3274 // Any big endian Power8 VSX subtarget.
3275 let Predicates = [HasVSX, HasP8Vector, IsBigEndian] in {
3276 def : Pat<DWToSPExtractConv.El0SS1,
3277 (f32 (XSCVSXDSP (COPY_TO_REGCLASS $S1, VSFRC)))>;
3278 def : Pat<DWToSPExtractConv.El1SS1,
3279 (f32 (XSCVSXDSP (COPY_TO_REGCLASS (XXPERMDI $S1, $S1, 2), VSFRC)))>;
3280 def : Pat<DWToSPExtractConv.El0US1,
3281 (f32 (XSCVUXDSP (COPY_TO_REGCLASS $S1, VSFRC)))>;
3282 def : Pat<DWToSPExtractConv.El1US1,
3283 (f32 (XSCVUXDSP (COPY_TO_REGCLASS (XXPERMDI $S1, $S1, 2), VSFRC)))>;
3285 // v4f32 scalar <-> vector conversions (BE)
3286 defm : ScalToVecWPermute<v4f32, (f32 f32:$A), (XSCVDPSPN $A), (XSCVDPSPN $A)>;
3287 def : Pat<(f32 (vector_extract v4f32:$S, 0)),
3288 (f32 (XSCVSPDPN $S))>;
3289 def : Pat<(f32 (vector_extract v4f32:$S, 1)),
3290 (f32 (XSCVSPDPN (XXSLDWI $S, $S, 1)))>;
3291 def : Pat<(f32 (vector_extract v4f32:$S, 2)),
3292 (f32 (XSCVSPDPN (XXPERMDI $S, $S, 2)))>;
3293 def : Pat<(f32 (vector_extract v4f32:$S, 3)),
3294 (f32 (XSCVSPDPN (XXSLDWI $S, $S, 3)))>;
3296 def : Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 0)))))),
3297 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 0))))>;
3298 def : Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 1)))))),
3299 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 1))))>;
3300 def : Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 2)))))),
3301 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 2))))>;
3302 def : Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 3)))))),
3303 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 3))))>;
3304 def : Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 0)))))),
3305 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 0)), VSFRC))>;
3306 def : Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 1)))))),
3307 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 1)), VSFRC))>;
3308 def : Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 2)))))),
3309 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 2)), VSFRC))>;
3310 def : Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 3)))))),
3311 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 3)), VSFRC))>;
3313 def : Pat<(f32 (vector_extract v4f32:$S, i32:$Idx)),
3314 (f32 VectorExtractions.BE_32B_VARIABLE_FLOAT)>;
3316 def : Pat<(f64 (vector_extract v2f64:$S, i32:$Idx)),
3317 (f64 VectorExtractions.BE_32B_VARIABLE_DOUBLE)>;
3318 } // HasVSX, HasP8Vector, IsBigEndian
3320 // Big endian Power8 64Bit VSX subtarget.
3321 let Predicates = [HasVSX, HasP8Vector, IsBigEndian, IsPPC64] in {
3322 def : Pat<(f32 (vector_extract v4f32:$S, i64:$Idx)),
3323 (f32 VectorExtractions.BE_VARIABLE_FLOAT)>;
3325 // LIWAX - This instruction is used for sign extending i32 -> i64.
3326 // LIWZX - This instruction will be emitted for i32, f32, and when
3327 // zero-extending i32 to i64 (zext i32 -> i64).
3328 def : Pat<(v2i64 (scalar_to_vector (i64 (sextloadi32 ForceXForm:$src)))),
3329 (v2i64 (SUBREG_TO_REG (i64 1), (LIWAX ForceXForm:$src), sub_64))>;
3330 def : Pat<(v2i64 (scalar_to_vector (i64 (zextloadi32 ForceXForm:$src)))),
3331 (v2i64 (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$src), sub_64))>;
3332 defm : ScalToVecWPermute<
3333 v4i32, (i32 (load ForceXForm:$src)),
3334 (XXSLDWIs (LIWZX ForceXForm:$src), 1),
3335 (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$src), sub_64)>;
3336 defm : ScalToVecWPermute<
3337 v4f32, (f32 (load ForceXForm:$src)),
3338 (XXSLDWIs (LIWZX ForceXForm:$src), 1),
3339 (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$src), sub_64)>;
3341 def : Pat<DWToSPExtractConv.BVU,
3342 (v4f32 (VPKUDUM (XXSLDWI (XVCVUXDSP $S1), (XVCVUXDSP $S1), 3),
3343 (XXSLDWI (XVCVUXDSP $S2), (XVCVUXDSP $S2), 3)))>;
3344 def : Pat<DWToSPExtractConv.BVS,
3345 (v4f32 (VPKUDUM (XXSLDWI (XVCVSXDSP $S1), (XVCVSXDSP $S1), 3),
3346 (XXSLDWI (XVCVSXDSP $S2), (XVCVSXDSP $S2), 3)))>;
3347 def : Pat<(store (i32 (extractelt v4i32:$A, 1)), ForceXForm:$src),
3348 (STIWX (EXTRACT_SUBREG $A, sub_64), ForceXForm:$src)>;
3349 def : Pat<(store (f32 (extractelt v4f32:$A, 1)), ForceXForm:$src),
3350 (STIWX (EXTRACT_SUBREG $A, sub_64), ForceXForm:$src)>;
3352 // Elements in a register on a BE system are in order <0, 1, 2, 3>.
3353 // The store instructions store the second word from the left.
3354 // So to align element zero, we need to modulo-left-shift by 3 words.
3355 // Similar logic applies for elements 2 and 3.
3356 foreach Idx = [ [0,3], [2,1], [3,2] ] in {
3357 def : Pat<(store (i32 (extractelt v4i32:$A, !head(Idx))), ForceXForm:$src),
3358 (STIWX (EXTRACT_SUBREG (XXSLDWI $A, $A, !head(!tail(Idx))),
3359 sub_64), ForceXForm:$src)>;
3360 def : Pat<(store (f32 (extractelt v4f32:$A, !head(Idx))), ForceXForm:$src),
3361 (STIWX (EXTRACT_SUBREG (XXSLDWI $A, $A, !head(!tail(Idx))),
3362 sub_64), ForceXForm:$src)>;
3364 } // HasVSX, HasP8Vector, IsBigEndian, IsPPC64
3366 // Little endian Power8 VSX subtarget.
3367 let Predicates = [HasVSX, HasP8Vector, IsLittleEndian] in {
3368 def : Pat<DWToSPExtractConv.El0SS1,
3369 (f32 (XSCVSXDSP (COPY_TO_REGCLASS (XXPERMDI $S1, $S1, 2), VSFRC)))>;
3370 def : Pat<DWToSPExtractConv.El1SS1,
3371 (f32 (XSCVSXDSP (COPY_TO_REGCLASS
3372 (f64 (COPY_TO_REGCLASS $S1, VSRC)), VSFRC)))>;
3373 def : Pat<DWToSPExtractConv.El0US1,
3374 (f32 (XSCVUXDSP (COPY_TO_REGCLASS (XXPERMDI $S1, $S1, 2), VSFRC)))>;
3375 def : Pat<DWToSPExtractConv.El1US1,
3376 (f32 (XSCVUXDSP (COPY_TO_REGCLASS
3377 (f64 (COPY_TO_REGCLASS $S1, VSRC)), VSFRC)))>;
3379 // v4f32 scalar <-> vector conversions (LE)
3380 defm : ScalToVecWPermute<v4f32, (f32 f32:$A),
3381 (XXSLDWI (XSCVDPSPN $A), (XSCVDPSPN $A), 1),
3383 def : Pat<(f32 (vector_extract v4f32:$S, 0)),
3384 (f32 (XSCVSPDPN (XXSLDWI $S, $S, 3)))>;
3385 def : Pat<(f32 (vector_extract v4f32:$S, 1)),
3386 (f32 (XSCVSPDPN (XXPERMDI $S, $S, 2)))>;
3387 def : Pat<(f32 (vector_extract v4f32:$S, 2)),
3388 (f32 (XSCVSPDPN (XXSLDWI $S, $S, 1)))>;
3389 def : Pat<(f32 (vector_extract v4f32:$S, 3)),
3390 (f32 (XSCVSPDPN $S))>;
3391 def : Pat<(f32 (vector_extract v4f32:$S, i64:$Idx)),
3392 (f32 VectorExtractions.LE_VARIABLE_FLOAT)>;
3394 def : Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 0)))))),
3395 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 3))))>;
3396 def : Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 1)))))),
3397 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 2))))>;
3398 def : Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 2)))))),
3399 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 1))))>;
3400 def : Pat<(f32 (PPCfcfids (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 3)))))),
3401 (f32 (XSCVSPDPN (XVCVSXWSP (XXSPLTW $A, 0))))>;
3402 def : Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 0)))))),
3403 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 3)), VSFRC))>;
3404 def : Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 1)))))),
3405 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 2)), VSFRC))>;
3406 def : Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 2)))))),
3407 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 1)), VSFRC))>;
3408 def : Pat<(f64 (PPCfcfid (f64 (PPCmtvsra (i32 (extractelt v4i32:$A, 3)))))),
3409 (f64 (COPY_TO_REGCLASS (XVCVSXWDP (XXSPLTW $A, 0)), VSFRC))>;
3411 // LIWAX - This instruction is used for sign extending i32 -> i64.
3412 // LIWZX - This instruction will be emitted for i32, f32, and when
3413 // zero-extending i32 to i64 (zext i32 -> i64).
3414 defm : ScalToVecWPermute<
3415 v2i64, (i64 (sextloadi32 ForceXForm:$src)),
3416 (XXPERMDIs (LIWAX ForceXForm:$src), 2),
3417 (SUBREG_TO_REG (i64 1), (LIWAX ForceXForm:$src), sub_64)>;
3419 defm : ScalToVecWPermute<
3420 v2i64, (i64 (zextloadi32 ForceXForm:$src)),
3421 (XXPERMDIs (LIWZX ForceXForm:$src), 2),
3422 (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$src), sub_64)>;
3424 defm : ScalToVecWPermute<
3425 v4i32, (i32 (load ForceXForm:$src)),
3426 (XXPERMDIs (LIWZX ForceXForm:$src), 2),
3427 (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$src), sub_64)>;
3429 defm : ScalToVecWPermute<
3430 v4f32, (f32 (load ForceXForm:$src)),
3431 (XXPERMDIs (LIWZX ForceXForm:$src), 2),
3432 (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$src), sub_64)>;
3434 def : Pat<DWToSPExtractConv.BVU,
3435 (v4f32 (VPKUDUM (XXSLDWI (XVCVUXDSP $S2), (XVCVUXDSP $S2), 3),
3436 (XXSLDWI (XVCVUXDSP $S1), (XVCVUXDSP $S1), 3)))>;
3437 def : Pat<DWToSPExtractConv.BVS,
3438 (v4f32 (VPKUDUM (XXSLDWI (XVCVSXDSP $S2), (XVCVSXDSP $S2), 3),
3439 (XXSLDWI (XVCVSXDSP $S1), (XVCVSXDSP $S1), 3)))>;
3440 def : Pat<(store (i32 (extractelt v4i32:$A, 2)), ForceXForm:$src),
3441 (STIWX (EXTRACT_SUBREG $A, sub_64), ForceXForm:$src)>;
3442 def : Pat<(store (f32 (extractelt v4f32:$A, 2)), ForceXForm:$src),
3443 (STIWX (EXTRACT_SUBREG $A, sub_64), ForceXForm:$src)>;
3445 // Elements in a register on a LE system are in order <3, 2, 1, 0>.
3446 // The store instructions store the second word from the left.
3447 // So to align element 3, we need to modulo-left-shift by 3 words.
3448 // Similar logic applies for elements 0 and 1.
3449 foreach Idx = [ [0,2], [1,1], [3,3] ] in {
3450 def : Pat<(store (i32 (extractelt v4i32:$A, !head(Idx))), ForceXForm:$src),
3451 (STIWX (EXTRACT_SUBREG (XXSLDWI $A, $A, !head(!tail(Idx))),
3452 sub_64), ForceXForm:$src)>;
3453 def : Pat<(store (f32 (extractelt v4f32:$A, !head(Idx))), ForceXForm:$src),
3454 (STIWX (EXTRACT_SUBREG (XXSLDWI $A, $A, !head(!tail(Idx))),
3455 sub_64), ForceXForm:$src)>;
3457 } // HasVSX, HasP8Vector, IsLittleEndian
3459 // Big endian pre-Power9 VSX subtarget.
3460 let Predicates = [HasVSX, HasP8Vector, NoP9Vector, IsBigEndian, IsPPC64] in {
3461 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), ForceXForm:$src),
3462 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), ForceXForm:$src)>;
3463 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), ForceXForm:$src),
3464 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), ForceXForm:$src)>;
3465 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), ForceXForm:$src),
3466 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2), sub_64),
3468 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), ForceXForm:$src),
3469 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2), sub_64),
3471 } // HasVSX, HasP8Vector, NoP9Vector, IsBigEndian, IsPPC64
3473 // Little endian pre-Power9 VSX subtarget.
3474 let Predicates = [HasVSX, HasP8Vector, NoP9Vector, IsLittleEndian] in {
3475 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), ForceXForm:$src),
3476 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2), sub_64),
3478 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), ForceXForm:$src),
3479 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2), sub_64),
3481 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), ForceXForm:$src),
3482 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), ForceXForm:$src)>;
3483 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), ForceXForm:$src),
3484 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), ForceXForm:$src)>;
3485 } // HasVSX, HasP8Vector, NoP9Vector, IsLittleEndian
3487 // Any VSX target with direct moves.
3488 let Predicates = [HasVSX, HasDirectMove] in {
3489 // bitconvert f32 -> i32
3490 // (convert to 32-bit fp single, shift right 1 word, move to GPR)
3491 def : Pat<(i32 (bitconvert f32:$A)), Bitcast.FltToInt>;
3493 // bitconvert i32 -> f32
3494 // (move to FPR, shift left 1 word, convert to 64-bit fp single)
3495 def : Pat<(f32 (bitconvert i32:$A)),
3497 (XXSLDWI MovesToVSR.LE_WORD_1, MovesToVSR.LE_WORD_1, 1)))>;
3499 // bitconvert f64 -> i64
3500 // (move to GPR, nothing else needed)
3501 def : Pat<(i64 (bitconvert f64:$A)), Bitcast.DblToLong>;
3503 // bitconvert i64 -> f64
3504 // (move to FPR, nothing else needed)
3505 def : Pat<(f64 (bitconvert i64:$S)),
3508 // Rounding to integer.
3509 def : Pat<(i64 (lrint f64:$S)),
3510 (i64 (MFVSRD (FCTID $S)))>;
3511 def : Pat<(i64 (lrint f32:$S)),
3512 (i64 (MFVSRD (FCTID (COPY_TO_REGCLASS $S, F8RC))))>;
3513 def : Pat<(i64 (llrint f64:$S)),
3514 (i64 (MFVSRD (FCTID $S)))>;
3515 def : Pat<(i64 (llrint f32:$S)),
3516 (i64 (MFVSRD (FCTID (COPY_TO_REGCLASS $S, F8RC))))>;
3517 def : Pat<(i64 (lround f64:$S)),
3518 (i64 (MFVSRD (FCTID (XSRDPI $S))))>;
3519 def : Pat<(i64 (lround f32:$S)),
3520 (i64 (MFVSRD (FCTID (XSRDPI (COPY_TO_REGCLASS $S, VSFRC)))))>;
3521 def : Pat<(i64 (llround f64:$S)),
3522 (i64 (MFVSRD (FCTID (XSRDPI $S))))>;
3523 def : Pat<(i64 (llround f32:$S)),
3524 (i64 (MFVSRD (FCTID (XSRDPI (COPY_TO_REGCLASS $S, VSFRC)))))>;
3526 // Alternate patterns for PPCmtvsrz where the output is v8i16 or v16i8 instead
3528 def : Pat<(v8i16 (PPCmtvsrz i32:$A)),
3529 (v8i16 (SUBREG_TO_REG (i64 1), (MTVSRWZ $A), sub_64))>;
3530 def : Pat<(v16i8 (PPCmtvsrz i32:$A)),
3531 (v16i8 (SUBREG_TO_REG (i64 1), (MTVSRWZ $A), sub_64))>;
3533 // Endianness-neutral constant splat on P8 and newer targets. The reason
3534 // for this pattern is that on targets with direct moves, we don't expand
3535 // BUILD_VECTOR nodes for v4i32.
3536 def : Pat<(v4i32 (build_vector immSExt5NonZero:$A, immSExt5NonZero:$A,
3537 immSExt5NonZero:$A, immSExt5NonZero:$A)),
3538 (v4i32 (VSPLTISW imm:$A))>;
3539 } // HasVSX, HasDirectMove
3541 // Big endian VSX subtarget with direct moves.
3542 let Predicates = [HasVSX, HasDirectMove, IsBigEndian] in {
3543 // v16i8 scalar <-> vector conversions (BE)
3544 defm : ScalToVecWPermute<
3545 v16i8, (i32 i32:$A),
3546 (SUBREG_TO_REG (i64 1), MovesToVSR.BE_BYTE_0, sub_64),
3547 (SUBREG_TO_REG (i64 1), (MTVSRWZ $A), sub_64)>;
3548 defm : ScalToVecWPermute<
3549 v8i16, (i32 i32:$A),
3550 (SUBREG_TO_REG (i64 1), MovesToVSR.BE_HALF_0, sub_64),
3551 (SUBREG_TO_REG (i64 1), (MTVSRWZ $A), sub_64)>;
3552 defm : ScalToVecWPermute<
3553 v4i32, (i32 i32:$A),
3554 (SUBREG_TO_REG (i64 1), MovesToVSR.BE_WORD_0, sub_64),
3555 (SUBREG_TO_REG (i64 1), (MTVSRWZ $A), sub_64)>;
3556 def : Pat<(v2i64 (scalar_to_vector i64:$A)),
3557 (v2i64 (SUBREG_TO_REG (i64 1), MovesToVSR.BE_DWORD_0, sub_64))>;
3559 // v2i64 scalar <-> vector conversions (BE)
3560 def : Pat<(i64 (vector_extract v2i64:$S, 0)),
3561 (i64 VectorExtractions.LE_DWORD_1)>;
3562 def : Pat<(i64 (vector_extract v2i64:$S, 1)),
3563 (i64 VectorExtractions.LE_DWORD_0)>;
3564 def : Pat<(i64 (vector_extract v2i64:$S, i64:$Idx)),
3565 (i64 VectorExtractions.BE_VARIABLE_DWORD)>;
3566 } // HasVSX, HasDirectMove, IsBigEndian
3568 // Little endian VSX subtarget with direct moves.
3569 let Predicates = [HasVSX, HasDirectMove, IsLittleEndian] in {
3570 // v16i8 scalar <-> vector conversions (LE)
3571 defm : ScalToVecWPermute<v16i8, (i32 i32:$A),
3572 (COPY_TO_REGCLASS MovesToVSR.LE_WORD_0, VSRC),
3573 (COPY_TO_REGCLASS MovesToVSR.LE_WORD_1, VSRC)>;
3574 defm : ScalToVecWPermute<v8i16, (i32 i32:$A),
3575 (COPY_TO_REGCLASS MovesToVSR.LE_WORD_0, VSRC),
3576 (COPY_TO_REGCLASS MovesToVSR.LE_WORD_1, VSRC)>;
3577 defm : ScalToVecWPermute<v4i32, (i32 i32:$A), MovesToVSR.LE_WORD_0,
3578 (SUBREG_TO_REG (i64 1), (MTVSRWZ $A), sub_64)>;
3579 defm : ScalToVecWPermute<v2i64, (i64 i64:$A), MovesToVSR.LE_DWORD_0,
3580 MovesToVSR.LE_DWORD_1>;
3582 // v2i64 scalar <-> vector conversions (LE)
3583 def : Pat<(i64 (vector_extract v2i64:$S, 0)),
3584 (i64 VectorExtractions.LE_DWORD_0)>;
3585 def : Pat<(i64 (vector_extract v2i64:$S, 1)),
3586 (i64 VectorExtractions.LE_DWORD_1)>;
3587 def : Pat<(i64 (vector_extract v2i64:$S, i64:$Idx)),
3588 (i64 VectorExtractions.LE_VARIABLE_DWORD)>;
3589 } // HasVSX, HasDirectMove, IsLittleEndian
3591 // Big endian pre-P9 VSX subtarget with direct moves.
3592 let Predicates = [HasVSX, HasDirectMove, NoP9Altivec, IsBigEndian] in {
3593 def : Pat<(i32 (vector_extract v16i8:$S, 0)),
3594 (i32 VectorExtractions.LE_BYTE_15)>;
3595 def : Pat<(i32 (vector_extract v16i8:$S, 1)),
3596 (i32 VectorExtractions.LE_BYTE_14)>;
3597 def : Pat<(i32 (vector_extract v16i8:$S, 2)),
3598 (i32 VectorExtractions.LE_BYTE_13)>;
3599 def : Pat<(i32 (vector_extract v16i8:$S, 3)),
3600 (i32 VectorExtractions.LE_BYTE_12)>;
3601 def : Pat<(i32 (vector_extract v16i8:$S, 4)),
3602 (i32 VectorExtractions.LE_BYTE_11)>;
3603 def : Pat<(i32 (vector_extract v16i8:$S, 5)),
3604 (i32 VectorExtractions.LE_BYTE_10)>;
3605 def : Pat<(i32 (vector_extract v16i8:$S, 6)),
3606 (i32 VectorExtractions.LE_BYTE_9)>;
3607 def : Pat<(i32 (vector_extract v16i8:$S, 7)),
3608 (i32 VectorExtractions.LE_BYTE_8)>;
3609 def : Pat<(i32 (vector_extract v16i8:$S, 8)),
3610 (i32 VectorExtractions.LE_BYTE_7)>;
3611 def : Pat<(i32 (vector_extract v16i8:$S, 9)),
3612 (i32 VectorExtractions.LE_BYTE_6)>;
3613 def : Pat<(i32 (vector_extract v16i8:$S, 10)),
3614 (i32 VectorExtractions.LE_BYTE_5)>;
3615 def : Pat<(i32 (vector_extract v16i8:$S, 11)),
3616 (i32 VectorExtractions.LE_BYTE_4)>;
3617 def : Pat<(i32 (vector_extract v16i8:$S, 12)),
3618 (i32 VectorExtractions.LE_BYTE_3)>;
3619 def : Pat<(i32 (vector_extract v16i8:$S, 13)),
3620 (i32 VectorExtractions.LE_BYTE_2)>;
3621 def : Pat<(i32 (vector_extract v16i8:$S, 14)),
3622 (i32 VectorExtractions.LE_BYTE_1)>;
3623 def : Pat<(i32 (vector_extract v16i8:$S, 15)),
3624 (i32 VectorExtractions.LE_BYTE_0)>;
3625 def : Pat<(i32 (vector_extract v16i8:$S, i64:$Idx)),
3626 (i32 VectorExtractions.BE_VARIABLE_BYTE)>;
3628 // v8i16 scalar <-> vector conversions (BE)
3629 def : Pat<(i32 (vector_extract v8i16:$S, 0)),
3630 (i32 VectorExtractions.LE_HALF_7)>;
3631 def : Pat<(i32 (vector_extract v8i16:$S, 1)),
3632 (i32 VectorExtractions.LE_HALF_6)>;
3633 def : Pat<(i32 (vector_extract v8i16:$S, 2)),
3634 (i32 VectorExtractions.LE_HALF_5)>;
3635 def : Pat<(i32 (vector_extract v8i16:$S, 3)),
3636 (i32 VectorExtractions.LE_HALF_4)>;
3637 def : Pat<(i32 (vector_extract v8i16:$S, 4)),
3638 (i32 VectorExtractions.LE_HALF_3)>;
3639 def : Pat<(i32 (vector_extract v8i16:$S, 5)),
3640 (i32 VectorExtractions.LE_HALF_2)>;
3641 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
3642 (i32 VectorExtractions.LE_HALF_1)>;
3643 def : Pat<(i32 (vector_extract v8i16:$S, 7)),
3644 (i32 VectorExtractions.LE_HALF_0)>;
3645 def : Pat<(i32 (vector_extract v8i16:$S, i64:$Idx)),
3646 (i32 VectorExtractions.BE_VARIABLE_HALF)>;
3648 // v4i32 scalar <-> vector conversions (BE)
3649 def : Pat<(i32 (vector_extract v4i32:$S, 0)),
3650 (i32 VectorExtractions.LE_WORD_3)>;
3651 def : Pat<(i32 (vector_extract v4i32:$S, 1)),
3652 (i32 VectorExtractions.LE_WORD_2)>;
3653 def : Pat<(i32 (vector_extract v4i32:$S, 2)),
3654 (i32 VectorExtractions.LE_WORD_1)>;
3655 def : Pat<(i32 (vector_extract v4i32:$S, 3)),
3656 (i32 VectorExtractions.LE_WORD_0)>;
3657 def : Pat<(i32 (vector_extract v4i32:$S, i64:$Idx)),
3658 (i32 VectorExtractions.BE_VARIABLE_WORD)>;
3659 } // HasVSX, HasDirectMove, NoP9Altivec, IsBigEndian
3661 // Little endian pre-P9 VSX subtarget with direct moves.
3662 let Predicates = [HasVSX, HasDirectMove, NoP9Altivec, IsLittleEndian] in {
3663 def : Pat<(i32 (vector_extract v16i8:$S, 0)),
3664 (i32 VectorExtractions.LE_BYTE_0)>;
3665 def : Pat<(i32 (vector_extract v16i8:$S, 1)),
3666 (i32 VectorExtractions.LE_BYTE_1)>;
3667 def : Pat<(i32 (vector_extract v16i8:$S, 2)),
3668 (i32 VectorExtractions.LE_BYTE_2)>;
3669 def : Pat<(i32 (vector_extract v16i8:$S, 3)),
3670 (i32 VectorExtractions.LE_BYTE_3)>;
3671 def : Pat<(i32 (vector_extract v16i8:$S, 4)),
3672 (i32 VectorExtractions.LE_BYTE_4)>;
3673 def : Pat<(i32 (vector_extract v16i8:$S, 5)),
3674 (i32 VectorExtractions.LE_BYTE_5)>;
3675 def : Pat<(i32 (vector_extract v16i8:$S, 6)),
3676 (i32 VectorExtractions.LE_BYTE_6)>;
3677 def : Pat<(i32 (vector_extract v16i8:$S, 7)),
3678 (i32 VectorExtractions.LE_BYTE_7)>;
3679 def : Pat<(i32 (vector_extract v16i8:$S, 8)),
3680 (i32 VectorExtractions.LE_BYTE_8)>;
3681 def : Pat<(i32 (vector_extract v16i8:$S, 9)),
3682 (i32 VectorExtractions.LE_BYTE_9)>;
3683 def : Pat<(i32 (vector_extract v16i8:$S, 10)),
3684 (i32 VectorExtractions.LE_BYTE_10)>;
3685 def : Pat<(i32 (vector_extract v16i8:$S, 11)),
3686 (i32 VectorExtractions.LE_BYTE_11)>;
3687 def : Pat<(i32 (vector_extract v16i8:$S, 12)),
3688 (i32 VectorExtractions.LE_BYTE_12)>;
3689 def : Pat<(i32 (vector_extract v16i8:$S, 13)),
3690 (i32 VectorExtractions.LE_BYTE_13)>;
3691 def : Pat<(i32 (vector_extract v16i8:$S, 14)),
3692 (i32 VectorExtractions.LE_BYTE_14)>;
3693 def : Pat<(i32 (vector_extract v16i8:$S, 15)),
3694 (i32 VectorExtractions.LE_BYTE_15)>;
3695 def : Pat<(i32 (vector_extract v16i8:$S, i64:$Idx)),
3696 (i32 VectorExtractions.LE_VARIABLE_BYTE)>;
3698 // v8i16 scalar <-> vector conversions (LE)
3699 def : Pat<(i32 (vector_extract v8i16:$S, 0)),
3700 (i32 VectorExtractions.LE_HALF_0)>;
3701 def : Pat<(i32 (vector_extract v8i16:$S, 1)),
3702 (i32 VectorExtractions.LE_HALF_1)>;
3703 def : Pat<(i32 (vector_extract v8i16:$S, 2)),
3704 (i32 VectorExtractions.LE_HALF_2)>;
3705 def : Pat<(i32 (vector_extract v8i16:$S, 3)),
3706 (i32 VectorExtractions.LE_HALF_3)>;
3707 def : Pat<(i32 (vector_extract v8i16:$S, 4)),
3708 (i32 VectorExtractions.LE_HALF_4)>;
3709 def : Pat<(i32 (vector_extract v8i16:$S, 5)),
3710 (i32 VectorExtractions.LE_HALF_5)>;
3711 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
3712 (i32 VectorExtractions.LE_HALF_6)>;
3713 def : Pat<(i32 (vector_extract v8i16:$S, 7)),
3714 (i32 VectorExtractions.LE_HALF_7)>;
3715 def : Pat<(i32 (vector_extract v8i16:$S, i64:$Idx)),
3716 (i32 VectorExtractions.LE_VARIABLE_HALF)>;
3718 // v4i32 scalar <-> vector conversions (LE)
3719 def : Pat<(i32 (vector_extract v4i32:$S, 0)),
3720 (i32 VectorExtractions.LE_WORD_0)>;
3721 def : Pat<(i32 (vector_extract v4i32:$S, 1)),
3722 (i32 VectorExtractions.LE_WORD_1)>;
3723 def : Pat<(i32 (vector_extract v4i32:$S, 2)),
3724 (i32 VectorExtractions.LE_WORD_2)>;
3725 def : Pat<(i32 (vector_extract v4i32:$S, 3)),
3726 (i32 VectorExtractions.LE_WORD_3)>;
3727 def : Pat<(i32 (vector_extract v4i32:$S, i64:$Idx)),
3728 (i32 VectorExtractions.LE_VARIABLE_WORD)>;
3729 } // HasVSX, HasDirectMove, NoP9Altivec, IsLittleEndian
3731 // Big endian pre-Power9 64Bit VSX subtarget that has direct moves.
3732 let Predicates = [HasVSX, HasDirectMove, NoP9Vector, IsBigEndian, IsPPC64] in {
3733 // Big endian integer vectors using direct moves.
3734 def : Pat<(v2i64 (build_vector i64:$A, i64:$B)),
3736 (SUBREG_TO_REG (i64 1), (MTVSRD $A), sub_64),
3737 (SUBREG_TO_REG (i64 1), (MTVSRD $B), sub_64), 0))>;
3738 def : Pat<(v4i32 (build_vector i32:$A, i32:$B, i32:$C, i32:$D)),
3740 (SUBREG_TO_REG (i64 1),
3741 (MTVSRD (RLDIMI AnyExts.B, AnyExts.A, 32, 0)), sub_64),
3742 (SUBREG_TO_REG (i64 1),
3743 (MTVSRD (RLDIMI AnyExts.D, AnyExts.C, 32, 0)), sub_64), 0)>;
3744 def : Pat<(v4i32 (build_vector i32:$A, i32:$A, i32:$A, i32:$A)),
3745 (XXSPLTW (SUBREG_TO_REG (i64 1), (MTVSRWZ $A), sub_64), 1)>;
3746 } // HasVSX, HasDirectMove, NoP9Vector, IsBigEndian, IsPPC64
3748 // Little endian pre-Power9 VSX subtarget that has direct moves.
3749 let Predicates = [HasVSX, HasDirectMove, NoP9Vector, IsLittleEndian] in {
3750 // Little endian integer vectors using direct moves.
3751 def : Pat<(v2i64 (build_vector i64:$A, i64:$B)),
3753 (SUBREG_TO_REG (i64 1), (MTVSRD $B), sub_64),
3754 (SUBREG_TO_REG (i64 1), (MTVSRD $A), sub_64), 0))>;
3755 def : Pat<(v4i32 (build_vector i32:$A, i32:$B, i32:$C, i32:$D)),
3757 (SUBREG_TO_REG (i64 1),
3758 (MTVSRD (RLDIMI AnyExts.C, AnyExts.D, 32, 0)), sub_64),
3759 (SUBREG_TO_REG (i64 1),
3760 (MTVSRD (RLDIMI AnyExts.A, AnyExts.B, 32, 0)), sub_64), 0)>;
3761 def : Pat<(v4i32 (build_vector i32:$A, i32:$A, i32:$A, i32:$A)),
3762 (XXSPLTW (SUBREG_TO_REG (i64 1), (MTVSRWZ $A), sub_64), 1)>;
3765 // Any Power9 VSX subtarget.
3766 let Predicates = [HasVSX, HasP9Vector] in {
3767 // Additional fnmsub pattern for PPC specific ISD opcode
3768 def : Pat<(PPCfnmsub f128:$A, f128:$B, f128:$C),
3769 (XSNMSUBQP $C, $A, $B)>;
3770 def : Pat<(fneg (PPCfnmsub f128:$A, f128:$B, f128:$C)),
3771 (XSMSUBQP $C, $A, $B)>;
3772 def : Pat<(PPCfnmsub f128:$A, f128:$B, (fneg f128:$C)),
3773 (XSNMADDQP $C, $A, $B)>;
3775 def : Pat<(f128 (any_sint_to_fp i64:$src)),
3776 (f128 (XSCVSDQP (COPY_TO_REGCLASS $src, VFRC)))>;
3777 def : Pat<(f128 (any_sint_to_fp (i64 (PPCmfvsr f64:$src)))),
3778 (f128 (XSCVSDQP $src))>;
3779 def : Pat<(f128 (any_sint_to_fp (i32 (PPCmfvsr f64:$src)))),
3780 (f128 (XSCVSDQP (VEXTSW2Ds $src)))>;
3781 def : Pat<(f128 (any_uint_to_fp i64:$src)),
3782 (f128 (XSCVUDQP (COPY_TO_REGCLASS $src, VFRC)))>;
3783 def : Pat<(f128 (any_uint_to_fp (i64 (PPCmfvsr f64:$src)))),
3784 (f128 (XSCVUDQP $src))>;
3786 // Convert (Un)Signed Word -> QP.
3787 def : Pat<(f128 (any_sint_to_fp i32:$src)),
3788 (f128 (XSCVSDQP (MTVSRWA $src)))>;
3789 def : Pat<(f128 (any_sint_to_fp (i32 (load ForceXForm:$src)))),
3790 (f128 (XSCVSDQP (LIWAX ForceXForm:$src)))>;
3791 def : Pat<(f128 (any_uint_to_fp i32:$src)),
3792 (f128 (XSCVUDQP (MTVSRWZ $src)))>;
3793 def : Pat<(f128 (any_uint_to_fp (i32 (load ForceXForm:$src)))),
3794 (f128 (XSCVUDQP (LIWZX ForceXForm:$src)))>;
3796 // Pattern for matching Vector HP -> Vector SP intrinsic. Defined as a
3797 // separate pattern so that it can convert the input register class from
3798 // VRRC(v8i16) to VSRC.
3799 def : Pat<(v4f32 (int_ppc_vsx_xvcvhpsp v8i16:$A)),
3800 (v4f32 (XVCVHPSP (COPY_TO_REGCLASS $A, VSRC)))>;
3802 // Use current rounding mode
3803 def : Pat<(f128 (any_fnearbyint f128:$vB)), (f128 (XSRQPI 0, $vB, 3))>;
3804 // Round to nearest, ties away from zero
3805 def : Pat<(f128 (any_fround f128:$vB)), (f128 (XSRQPI 0, $vB, 0))>;
3806 // Round towards Zero
3807 def : Pat<(f128 (any_ftrunc f128:$vB)), (f128 (XSRQPI 1, $vB, 1))>;
3808 // Round towards +Inf
3809 def : Pat<(f128 (any_fceil f128:$vB)), (f128 (XSRQPI 1, $vB, 2))>;
3810 // Round towards -Inf
3811 def : Pat<(f128 (any_ffloor f128:$vB)), (f128 (XSRQPI 1, $vB, 3))>;
3812 // Use current rounding mode, [with Inexact]
3813 def : Pat<(f128 (any_frint f128:$vB)), (f128 (XSRQPIX 0, $vB, 3))>;
3815 def : Pat<(f128 (int_ppc_scalar_insert_exp_qp f128:$vA, i64:$vB)),
3816 (f128 (XSIEXPQP $vA, (MTVSRD $vB)))>;
3818 def : Pat<(i64 (int_ppc_scalar_extract_expq f128:$vA)),
3819 (i64 (MFVSRD (EXTRACT_SUBREG
3820 (v2i64 (XSXEXPQP $vA)), sub_64)))>;
3822 // Extra patterns expanding to vector Extract Word/Insert Word
3823 def : Pat<(v4i32 (int_ppc_vsx_xxinsertw v4i32:$A, v2i64:$B, imm:$IMM)),
3824 (v4i32 (XXINSERTW $A, $B, imm:$IMM))>;
3825 def : Pat<(v2i64 (int_ppc_vsx_xxextractuw v2i64:$A, imm:$IMM)),
3826 (v2i64 (COPY_TO_REGCLASS (XXEXTRACTUW $A, imm:$IMM), VSRC))>;
3829 def : Pat<(v8i16 (bswap v8i16 :$A)),
3830 (v8i16 (COPY_TO_REGCLASS (XXBRH (COPY_TO_REGCLASS $A, VSRC)), VRRC))>;
3831 def : Pat<(v1i128 (bswap v1i128 :$A)),
3832 (v1i128 (COPY_TO_REGCLASS (XXBRQ (COPY_TO_REGCLASS $A, VSRC)), VRRC))>;
3834 // D-Form Load/Store
3835 foreach Ty = [v4i32, v4f32, v2i64, v2f64] in {
3836 def : Pat<(Ty (load DQForm:$src)), (LXV memrix16:$src)>;
3837 def : Pat<(Ty (load XForm:$src)), (LXVX XForm:$src)>;
3838 def : Pat<(store Ty:$rS, DQForm:$dst), (STXV $rS, memrix16:$dst)>;
3839 def : Pat<(store Ty:$rS, XForm:$dst), (STXVX $rS, XForm:$dst)>;
3842 def : Pat<(f128 (load DQForm:$src)),
3843 (COPY_TO_REGCLASS (LXV memrix16:$src), VRRC)>;
3844 def : Pat<(f128 (load XForm:$src)),
3845 (COPY_TO_REGCLASS (LXVX XForm:$src), VRRC)>;
3846 def : Pat<(v4i32 (int_ppc_vsx_lxvw4x DQForm:$src)), (LXV memrix16:$src)>;
3847 def : Pat<(v2f64 (int_ppc_vsx_lxvd2x DQForm:$src)), (LXV memrix16:$src)>;
3848 def : Pat<(v4i32 (int_ppc_vsx_lxvw4x XForm:$src)), (LXVX XForm:$src)>;
3849 def : Pat<(v2f64 (int_ppc_vsx_lxvd2x XForm:$src)), (LXVX XForm:$src)>;
3851 def : Pat<(store f128:$rS, DQForm:$dst),
3852 (STXV (COPY_TO_REGCLASS $rS, VSRC), memrix16:$dst)>;
3853 def : Pat<(store f128:$rS, XForm:$dst),
3854 (STXVX (COPY_TO_REGCLASS $rS, VSRC), XForm:$dst)>;
3855 def : Pat<(int_ppc_vsx_stxvw4x v4i32:$rS, DQForm:$dst),
3856 (STXV $rS, memrix16:$dst)>;
3857 def : Pat<(int_ppc_vsx_stxvd2x v2f64:$rS, DQForm:$dst),
3858 (STXV $rS, memrix16:$dst)>;
3859 def : Pat<(int_ppc_vsx_stxvw4x v4i32:$rS, XForm:$dst),
3860 (STXVX $rS, XForm:$dst)>;
3861 def : Pat<(int_ppc_vsx_stxvd2x v2f64:$rS, XForm:$dst),
3862 (STXVX $rS, XForm:$dst)>;
3864 // Build vectors from i8 loads
3865 defm : ScalToVecWPermute<v8i16, ScalarLoads.ZELi8,
3866 (VSPLTHs 3, (LXSIBZX ForceXForm:$src)),
3867 (SUBREG_TO_REG (i64 1), (LXSIBZX ForceXForm:$src), sub_64)>;
3868 defm : ScalToVecWPermute<v4i32, ScalarLoads.ZELi8,
3869 (XXSPLTWs (LXSIBZX ForceXForm:$src), 1),
3870 (SUBREG_TO_REG (i64 1), (LXSIBZX ForceXForm:$src), sub_64)>;
3871 defm : ScalToVecWPermute<v2i64, ScalarLoads.ZELi8i64,
3872 (XXPERMDIs (LXSIBZX ForceXForm:$src), 0),
3873 (SUBREG_TO_REG (i64 1), (LXSIBZX ForceXForm:$src), sub_64)>;
3874 defm : ScalToVecWPermute<
3875 v4i32, ScalarLoads.SELi8,
3876 (XXSPLTWs (VEXTSB2Ws (LXSIBZX ForceXForm:$src)), 1),
3877 (SUBREG_TO_REG (i64 1), (VEXTSB2Ws (LXSIBZX ForceXForm:$src)), sub_64)>;
3878 defm : ScalToVecWPermute<
3879 v2i64, ScalarLoads.SELi8i64,
3880 (XXPERMDIs (VEXTSB2Ds (LXSIBZX ForceXForm:$src)), 0),
3881 (SUBREG_TO_REG (i64 1), (VEXTSB2Ds (LXSIBZX ForceXForm:$src)), sub_64)>;
3883 // Build vectors from i16 loads
3884 defm : ScalToVecWPermute<
3885 v4i32, ScalarLoads.ZELi16,
3886 (XXSPLTWs (LXSIHZX ForceXForm:$src), 1),
3887 (SUBREG_TO_REG (i64 1), (LXSIHZX ForceXForm:$src), sub_64)>;
3888 defm : ScalToVecWPermute<
3889 v2i64, ScalarLoads.ZELi16i64,
3890 (XXPERMDIs (LXSIHZX ForceXForm:$src), 0),
3891 (SUBREG_TO_REG (i64 1), (LXSIHZX ForceXForm:$src), sub_64)>;
3892 defm : ScalToVecWPermute<
3893 v4i32, ScalarLoads.SELi16,
3894 (XXSPLTWs (VEXTSH2Ws (LXSIHZX ForceXForm:$src)), 1),
3895 (SUBREG_TO_REG (i64 1), (VEXTSH2Ws (LXSIHZX ForceXForm:$src)), sub_64)>;
3896 defm : ScalToVecWPermute<
3897 v2i64, ScalarLoads.SELi16i64,
3898 (XXPERMDIs (VEXTSH2Ds (LXSIHZX ForceXForm:$src)), 0),
3899 (SUBREG_TO_REG (i64 1), (VEXTSH2Ds (LXSIHZX ForceXForm:$src)), sub_64)>;
3901 // Load/convert and convert/store patterns for f16.
3902 def : Pat<(f64 (extloadf16 ForceXForm:$src)),
3903 (f64 (XSCVHPDP (LXSIHZX ForceXForm:$src)))>;
3904 def : Pat<(truncstoref16 f64:$src, ForceXForm:$dst),
3905 (STXSIHX (XSCVDPHP $src), ForceXForm:$dst)>;
3906 def : Pat<(f32 (extloadf16 ForceXForm:$src)),
3907 (f32 (COPY_TO_REGCLASS (XSCVHPDP (LXSIHZX ForceXForm:$src)), VSSRC))>;
3908 def : Pat<(truncstoref16 f32:$src, ForceXForm:$dst),
3909 (STXSIHX (XSCVDPHP (COPY_TO_REGCLASS $src, VSFRC)), ForceXForm:$dst)>;
3910 def : Pat<(f64 (f16_to_fp i32:$A)),
3911 (f64 (XSCVHPDP (MTVSRWZ $A)))>;
3912 def : Pat<(f32 (f16_to_fp i32:$A)),
3913 (f32 (COPY_TO_REGCLASS (XSCVHPDP (MTVSRWZ $A)), VSSRC))>;
3914 def : Pat<(i32 (fp_to_f16 f32:$A)),
3915 (i32 (MFVSRWZ (XSCVDPHP (COPY_TO_REGCLASS $A, VSFRC))))>;
3916 def : Pat<(i32 (fp_to_f16 f64:$A)), (i32 (MFVSRWZ (XSCVDPHP $A)))>;
3918 // Vector sign extensions
3919 def : Pat<(f64 (PPCVexts f64:$A, 1)),
3920 (f64 (COPY_TO_REGCLASS (VEXTSB2Ds $A), VSFRC))>;
3921 def : Pat<(f64 (PPCVexts f64:$A, 2)),
3922 (f64 (COPY_TO_REGCLASS (VEXTSH2Ds $A), VSFRC))>;
3924 def : Pat<(f64 (extloadf32 DSForm:$src)),
3925 (COPY_TO_REGCLASS (DFLOADf32 DSForm:$src), VSFRC)>;
3926 def : Pat<(f32 (fpround (f64 (extloadf32 DSForm:$src)))),
3927 (f32 (DFLOADf32 DSForm:$src))>;
3929 def : Pat<(v4f32 (PPCldvsxlh XForm:$src)),
3930 (SUBREG_TO_REG (i64 1), (XFLOADf64 XForm:$src), sub_64)>;
3931 def : Pat<(v4f32 (PPCldvsxlh DSForm:$src)),
3932 (SUBREG_TO_REG (i64 1), (DFLOADf64 DSForm:$src), sub_64)>;
3934 // Convert (Un)Signed DWord in memory -> QP
3935 def : Pat<(f128 (sint_to_fp (i64 (load XForm:$src)))),
3936 (f128 (XSCVSDQP (LXSDX XForm:$src)))>;
3937 def : Pat<(f128 (sint_to_fp (i64 (load DSForm:$src)))),
3938 (f128 (XSCVSDQP (LXSD DSForm:$src)))>;
3939 def : Pat<(f128 (uint_to_fp (i64 (load XForm:$src)))),
3940 (f128 (XSCVUDQP (LXSDX XForm:$src)))>;
3941 def : Pat<(f128 (uint_to_fp (i64 (load DSForm:$src)))),
3942 (f128 (XSCVUDQP (LXSD DSForm:$src)))>;
3944 // Convert Unsigned HWord in memory -> QP
3945 def : Pat<(f128 (uint_to_fp ScalarLoads.ZELi16)),
3946 (f128 (XSCVUDQP (LXSIHZX XForm:$src)))>;
3948 // Convert Unsigned Byte in memory -> QP
3949 def : Pat<(f128 (uint_to_fp ScalarLoads.ZELi8)),
3950 (f128 (XSCVUDQP (LXSIBZX ForceXForm:$src)))>;
3952 // Truncate & Convert QP -> (Un)Signed (D)Word.
3953 def : Pat<(i64 (any_fp_to_sint f128:$src)), (i64 (MFVRD (XSCVQPSDZ $src)))>;
3954 def : Pat<(i64 (any_fp_to_uint f128:$src)), (i64 (MFVRD (XSCVQPUDZ $src)))>;
3955 def : Pat<(i32 (any_fp_to_sint f128:$src)),
3956 (i32 (MFVSRWZ (COPY_TO_REGCLASS (XSCVQPSWZ $src), VFRC)))>;
3957 def : Pat<(i32 (any_fp_to_uint f128:$src)),
3958 (i32 (MFVSRWZ (COPY_TO_REGCLASS (XSCVQPUWZ $src), VFRC)))>;
3960 // Instructions for store(fptosi).
3961 // The 8-byte version is repeated here due to availability of D-Form STXSD.
3962 def : Pat<(PPCstore_scal_int_from_vsr
3963 (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)), XForm:$dst, 8),
3964 (STXSDX (COPY_TO_REGCLASS (XSCVQPSDZ f128:$src), VFRC),
3966 def : Pat<(PPCstore_scal_int_from_vsr
3967 (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)), DSForm:$dst, 8),
3968 (STXSD (COPY_TO_REGCLASS (XSCVQPSDZ f128:$src), VFRC),
3970 def : Pat<(PPCstore_scal_int_from_vsr
3971 (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)), ForceXForm:$dst, 4),
3972 (STXSIWX (COPY_TO_REGCLASS (XSCVQPSWZ $src), VFRC), ForceXForm:$dst)>;
3973 def : Pat<(PPCstore_scal_int_from_vsr
3974 (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)), ForceXForm:$dst, 2),
3975 (STXSIHX (COPY_TO_REGCLASS (XSCVQPSWZ $src), VFRC), ForceXForm:$dst)>;
3976 def : Pat<(PPCstore_scal_int_from_vsr
3977 (f64 (PPCcv_fp_to_sint_in_vsr f128:$src)), ForceXForm:$dst, 1),
3978 (STXSIBX (COPY_TO_REGCLASS (XSCVQPSWZ $src), VFRC), ForceXForm:$dst)>;
3979 def : Pat<(PPCstore_scal_int_from_vsr
3980 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), XForm:$dst, 8),
3981 (STXSDX (XSCVDPSXDS f64:$src), XForm:$dst)>;
3982 def : Pat<(PPCstore_scal_int_from_vsr
3983 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), DSForm:$dst, 8),
3984 (STXSD (XSCVDPSXDS f64:$src), DSForm:$dst)>;
3985 def : Pat<(PPCstore_scal_int_from_vsr
3986 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), ForceXForm:$dst, 2),
3987 (STXSIHX (XSCVDPSXWS f64:$src), ForceXForm:$dst)>;
3988 def : Pat<(PPCstore_scal_int_from_vsr
3989 (f64 (PPCcv_fp_to_sint_in_vsr f64:$src)), ForceXForm:$dst, 1),
3990 (STXSIBX (XSCVDPSXWS f64:$src), ForceXForm:$dst)>;
3992 // Instructions for store(fptoui).
3993 def : Pat<(PPCstore_scal_int_from_vsr
3994 (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)), XForm:$dst, 8),
3995 (STXSDX (COPY_TO_REGCLASS (XSCVQPUDZ f128:$src), VFRC),
3997 def : Pat<(PPCstore_scal_int_from_vsr
3998 (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)), DSForm:$dst, 8),
3999 (STXSD (COPY_TO_REGCLASS (XSCVQPUDZ f128:$src), VFRC),
4001 def : Pat<(PPCstore_scal_int_from_vsr
4002 (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)), ForceXForm:$dst, 4),
4003 (STXSIWX (COPY_TO_REGCLASS (XSCVQPUWZ $src), VFRC), ForceXForm:$dst)>;
4004 def : Pat<(PPCstore_scal_int_from_vsr
4005 (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)), ForceXForm:$dst, 2),
4006 (STXSIHX (COPY_TO_REGCLASS (XSCVQPUWZ $src), VFRC), ForceXForm:$dst)>;
4007 def : Pat<(PPCstore_scal_int_from_vsr
4008 (f64 (PPCcv_fp_to_uint_in_vsr f128:$src)), ForceXForm:$dst, 1),
4009 (STXSIBX (COPY_TO_REGCLASS (XSCVQPUWZ $src), VFRC), ForceXForm:$dst)>;
4010 def : Pat<(PPCstore_scal_int_from_vsr
4011 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), XForm:$dst, 8),
4012 (STXSDX (XSCVDPUXDS f64:$src), XForm:$dst)>;
4013 def : Pat<(PPCstore_scal_int_from_vsr
4014 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), DSForm:$dst, 8),
4015 (STXSD (XSCVDPUXDS f64:$src), DSForm:$dst)>;
4016 def : Pat<(PPCstore_scal_int_from_vsr
4017 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), ForceXForm:$dst, 2),
4018 (STXSIHX (XSCVDPUXWS f64:$src), ForceXForm:$dst)>;
4019 def : Pat<(PPCstore_scal_int_from_vsr
4020 (f64 (PPCcv_fp_to_uint_in_vsr f64:$src)), ForceXForm:$dst, 1),
4021 (STXSIBX (XSCVDPUXWS f64:$src), ForceXForm:$dst)>;
4023 // Round & Convert QP -> DP/SP
4024 def : Pat<(f64 (any_fpround f128:$src)), (f64 (XSCVQPDP $src))>;
4025 def : Pat<(f32 (any_fpround f128:$src)), (f32 (XSRSP (XSCVQPDPO $src)))>;
4028 def : Pat<(f128 (any_fpextend f32:$src)),
4029 (f128 (XSCVDPQP (COPY_TO_REGCLASS $src, VFRC)))>;
4031 def : Pat<(f32 (PPCxsmaxc f32:$XA, f32:$XB)),
4032 (f32 (COPY_TO_REGCLASS (XSMAXCDP (COPY_TO_REGCLASS $XA, VSSRC),
4033 (COPY_TO_REGCLASS $XB, VSSRC)),
4035 def : Pat<(f32 (PPCxsminc f32:$XA, f32:$XB)),
4036 (f32 (COPY_TO_REGCLASS (XSMINCDP (COPY_TO_REGCLASS $XA, VSSRC),
4037 (COPY_TO_REGCLASS $XB, VSSRC)),
4040 // Endianness-neutral patterns for const splats with ISA 3.0 instructions.
4041 defm : ScalToVecWPermute<v4i32, (i32 i32:$A), (MTVSRWS $A),
4042 (SUBREG_TO_REG (i64 1), (MTVSRWZ $A), sub_64)>;
4043 def : Pat<(v4i32 (build_vector i32:$A, i32:$A, i32:$A, i32:$A)),
4044 (v4i32 (MTVSRWS $A))>;
4045 def : Pat<(v16i8 (build_vector immNonAllOneAnyExt8:$A, immNonAllOneAnyExt8:$A,
4046 immNonAllOneAnyExt8:$A, immNonAllOneAnyExt8:$A,
4047 immNonAllOneAnyExt8:$A, immNonAllOneAnyExt8:$A,
4048 immNonAllOneAnyExt8:$A, immNonAllOneAnyExt8:$A,
4049 immNonAllOneAnyExt8:$A, immNonAllOneAnyExt8:$A,
4050 immNonAllOneAnyExt8:$A, immNonAllOneAnyExt8:$A,
4051 immNonAllOneAnyExt8:$A, immNonAllOneAnyExt8:$A,
4052 immNonAllOneAnyExt8:$A, immNonAllOneAnyExt8:$A)),
4053 (v16i8 (COPY_TO_REGCLASS (XXSPLTIB imm:$A), VSRC))>;
4054 defm : ScalToVecWPermute<
4055 v4i32, FltToIntLoad.A,
4056 (XVCVSPSXWS (LXVWSX ForceXForm:$A)),
4057 (XVCVSPSXWS (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$A), sub_64))>;
4058 defm : ScalToVecWPermute<
4059 v4i32, FltToUIntLoad.A,
4060 (XVCVSPUXWS (LXVWSX ForceXForm:$A)),
4061 (XVCVSPUXWS (SUBREG_TO_REG (i64 1), (LIWZX ForceXForm:$A), sub_64))>;
4062 defm : ScalToVecWPermute<
4063 v4i32, DblToIntLoadP9.A,
4064 (XXSPLTW (SUBREG_TO_REG (i64 1), (XSCVDPSXWS (DFLOADf64 DSForm:$A)), sub_64), 1),
4065 (SUBREG_TO_REG (i64 1), (XSCVDPSXWS (DFLOADf64 DSForm:$A)), sub_64)>;
4066 defm : ScalToVecWPermute<
4067 v4i32, DblToUIntLoadP9.A,
4068 (XXSPLTW (SUBREG_TO_REG (i64 1), (XSCVDPUXWS (DFLOADf64 DSForm:$A)), sub_64), 1),
4069 (SUBREG_TO_REG (i64 1), (XSCVDPUXWS (DFLOADf64 DSForm:$A)), sub_64)>;
4070 defm : ScalToVecWPermute<
4071 v2i64, FltToLongLoadP9.A,
4072 (XXPERMDIs (XSCVDPSXDS (COPY_TO_REGCLASS (DFLOADf32 DSForm:$A), VSFRC)), 0),
4075 (XSCVDPSXDS (COPY_TO_REGCLASS (DFLOADf32 DSForm:$A), VSFRC)), sub_64)>;
4076 defm : ScalToVecWPermute<
4077 v2i64, FltToULongLoadP9.A,
4078 (XXPERMDIs (XSCVDPUXDS (COPY_TO_REGCLASS (DFLOADf32 DSForm:$A), VSFRC)), 0),
4081 (XSCVDPUXDS (COPY_TO_REGCLASS (DFLOADf32 DSForm:$A), VSFRC)), sub_64)>;
4082 def : Pat<(v4f32 (PPCldsplat ForceXForm:$A)),
4083 (v4f32 (LXVWSX ForceXForm:$A))>;
4084 def : Pat<(v4i32 (PPCldsplat ForceXForm:$A)),
4085 (v4i32 (LXVWSX ForceXForm:$A))>;
4086 } // HasVSX, HasP9Vector
4088 // Any Power9 VSX subtarget with equivalent length but better Power10 VSX
4090 // Two identical blocks are required due to the slightly different predicates:
4091 // One without P10 instructions, the other is BigEndian only with P10 instructions.
4092 let Predicates = [HasVSX, HasP9Vector, NoP10Vector] in {
4093 // Little endian Power10 subtargets produce a shorter pattern but require a
4094 // COPY_TO_REGCLASS. The COPY_TO_REGCLASS makes it appear to need two instructions
4095 // to perform the operation, when only one instruction is produced in practice.
4096 // The NoP10Vector predicate excludes these patterns from Power10 VSX subtargets.
4097 defm : ScalToVecWPermute<
4098 v16i8, ScalarLoads.Li8,
4099 (VSPLTBs 7, (LXSIBZX ForceXForm:$src)),
4100 (SUBREG_TO_REG (i64 1), (LXSIBZX ForceXForm:$src), sub_64)>;
4101 // Build vectors from i16 loads
4102 defm : ScalToVecWPermute<
4103 v8i16, ScalarLoads.Li16,
4104 (VSPLTHs 3, (LXSIHZX ForceXForm:$src)),
4105 (SUBREG_TO_REG (i64 1), (LXSIHZX ForceXForm:$src), sub_64)>;
4106 } // HasVSX, HasP9Vector, NoP10Vector
4108 // Any big endian Power9 VSX subtarget
4109 let Predicates = [HasVSX, HasP9Vector, IsBigEndian] in {
4110 // Power10 VSX subtargets produce a shorter pattern for little endian targets
4111 // but this is still the best pattern for Power9 and Power10 VSX big endian
4112 // Build vectors from i8 loads
4113 defm : ScalToVecWPermute<
4114 v16i8, ScalarLoads.Li8,
4115 (VSPLTBs 7, (LXSIBZX ForceXForm:$src)),
4116 (SUBREG_TO_REG (i64 1), (LXSIBZX ForceXForm:$src), sub_64)>;
4117 // Build vectors from i16 loads
4118 defm : ScalToVecWPermute<
4119 v8i16, ScalarLoads.Li16,
4120 (VSPLTHs 3, (LXSIHZX ForceXForm:$src)),
4121 (SUBREG_TO_REG (i64 1), (LXSIHZX ForceXForm:$src), sub_64)>;
4123 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 0)))))),
4124 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 0)))>;
4125 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 1)))))),
4126 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 4)))>;
4127 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 2)))))),
4128 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 8)))>;
4129 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 3)))))),
4130 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 12)))>;
4131 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 0)))))),
4132 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 0)))>;
4133 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 1)))))),
4134 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 4)))>;
4135 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 2)))))),
4136 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 8)))>;
4137 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 3)))))),
4138 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 12)))>;
4139 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 0)),
4140 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 0))>;
4141 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 1)),
4142 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 4))>;
4143 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 2)),
4144 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 8))>;
4145 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 3)),
4146 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 12))>;
4147 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 0)),
4148 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 0))>;
4149 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 1)),
4150 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 4))>;
4151 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 2)),
4152 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 8))>;
4153 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 3)),
4154 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 12))>;
4156 def : Pat<(v4f32 (insertelt v4f32:$A, (f32 (fpround f64:$B)), 0)),
4157 (v4f32 (XXINSERTW v4f32:$A,
4158 (SUBREG_TO_REG (i64 1), (XSCVDPSP f64:$B), sub_64), 0))>;
4159 def : Pat<(v4f32 (insertelt v4f32:$A, (f32 (fpround f64:$B)), 1)),
4160 (v4f32 (XXINSERTW v4f32:$A,
4161 (SUBREG_TO_REG (i64 1), (XSCVDPSP f64:$B), sub_64), 4))>;
4162 def : Pat<(v4f32 (insertelt v4f32:$A, (f32 (fpround f64:$B)), 2)),
4163 (v4f32 (XXINSERTW v4f32:$A,
4164 (SUBREG_TO_REG (i64 1), (XSCVDPSP f64:$B), sub_64), 8))>;
4165 def : Pat<(v4f32 (insertelt v4f32:$A, (f32 (fpround f64:$B)), 3)),
4166 (v4f32 (XXINSERTW v4f32:$A,
4167 (SUBREG_TO_REG (i64 1), (XSCVDPSP f64:$B), sub_64), 12))>;
4169 // Scalar stores of i8
4170 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 0)), ForceXForm:$dst),
4171 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 9)), VSRC), ForceXForm:$dst)>;
4172 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 1)), ForceXForm:$dst),
4173 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 10)), VSRC), ForceXForm:$dst)>;
4174 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 2)), ForceXForm:$dst),
4175 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 11)), VSRC), ForceXForm:$dst)>;
4176 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 3)), ForceXForm:$dst),
4177 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 12)), VSRC), ForceXForm:$dst)>;
4178 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 4)), ForceXForm:$dst),
4179 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 13)), VSRC), ForceXForm:$dst)>;
4180 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 5)), ForceXForm:$dst),
4181 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 14)), VSRC), ForceXForm:$dst)>;
4182 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 6)), ForceXForm:$dst),
4183 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 15)), VSRC), ForceXForm:$dst)>;
4184 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 7)), ForceXForm:$dst),
4185 (STXSIBXv (COPY_TO_REGCLASS $S, VSRC), ForceXForm:$dst)>;
4186 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 8)), ForceXForm:$dst),
4187 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 1)), VSRC), ForceXForm:$dst)>;
4188 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 9)), ForceXForm:$dst),
4189 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 2)), VSRC), ForceXForm:$dst)>;
4190 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 10)), ForceXForm:$dst),
4191 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 3)), VSRC), ForceXForm:$dst)>;
4192 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 11)), ForceXForm:$dst),
4193 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 4)), VSRC), ForceXForm:$dst)>;
4194 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 12)), ForceXForm:$dst),
4195 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 5)), VSRC), ForceXForm:$dst)>;
4196 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 13)), ForceXForm:$dst),
4197 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 6)), VSRC), ForceXForm:$dst)>;
4198 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 14)), ForceXForm:$dst),
4199 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 7)), VSRC), ForceXForm:$dst)>;
4200 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 15)), ForceXForm:$dst),
4201 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 8)), VSRC), ForceXForm:$dst)>;
4203 // Scalar stores of i16
4204 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 0)), ForceXForm:$dst),
4205 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 10)), VSRC), ForceXForm:$dst)>;
4206 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 1)), ForceXForm:$dst),
4207 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 12)), VSRC), ForceXForm:$dst)>;
4208 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 2)), ForceXForm:$dst),
4209 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 14)), VSRC), ForceXForm:$dst)>;
4210 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 3)), ForceXForm:$dst),
4211 (STXSIHXv (COPY_TO_REGCLASS $S, VSRC), ForceXForm:$dst)>;
4212 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 4)), ForceXForm:$dst),
4213 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 2)), VSRC), ForceXForm:$dst)>;
4214 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 5)), ForceXForm:$dst),
4215 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 4)), VSRC), ForceXForm:$dst)>;
4216 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 6)), ForceXForm:$dst),
4217 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 6)), VSRC), ForceXForm:$dst)>;
4218 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 7)), ForceXForm:$dst),
4219 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 8)), VSRC), ForceXForm:$dst)>;
4220 } // HasVSX, HasP9Vector, IsBigEndian
4222 // Big endian 64Bit Power9 subtarget.
4223 let Predicates = [HasVSX, HasP9Vector, IsBigEndian, IsPPC64] in {
4224 def : Pat<(v2i64 (scalar_to_vector (i64 (load DSForm:$src)))),
4225 (v2i64 (SUBREG_TO_REG (i64 1), (DFLOADf64 DSForm:$src), sub_64))>;
4226 def : Pat<(v2i64 (scalar_to_vector (i64 (load XForm:$src)))),
4227 (v2i64 (SUBREG_TO_REG (i64 1), (XFLOADf64 XForm:$src), sub_64))>;
4229 def : Pat<(v2f64 (scalar_to_vector (f64 (load DSForm:$src)))),
4230 (v2f64 (SUBREG_TO_REG (i64 1), (DFLOADf64 DSForm:$src), sub_64))>;
4231 def : Pat<(v2f64 (scalar_to_vector (f64 (load XForm:$src)))),
4232 (v2f64 (SUBREG_TO_REG (i64 1), (XFLOADf64 XForm:$src), sub_64))>;
4233 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), XForm:$src),
4234 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
4235 sub_64), XForm:$src)>;
4236 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), XForm:$src),
4237 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
4238 sub_64), XForm:$src)>;
4239 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), XForm:$src),
4240 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), XForm:$src)>;
4241 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), XForm:$src),
4242 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), XForm:$src)>;
4243 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), DSForm:$src),
4244 (DFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
4245 sub_64), DSForm:$src)>;
4246 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), DSForm:$src),
4247 (DFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
4248 sub_64), DSForm:$src)>;
4249 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), DSForm:$src),
4250 (DFSTOREf64 (EXTRACT_SUBREG $A, sub_64), DSForm:$src)>;
4251 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), DSForm:$src),
4252 (DFSTOREf64 (EXTRACT_SUBREG $A, sub_64), DSForm:$src)>;
4254 // (Un)Signed DWord vector extract -> QP
4255 def : Pat<(f128 (sint_to_fp (i64 (extractelt v2i64:$src, 0)))),
4256 (f128 (XSCVSDQP (COPY_TO_REGCLASS $src, VFRC)))>;
4257 def : Pat<(f128 (sint_to_fp (i64 (extractelt v2i64:$src, 1)))),
4259 (EXTRACT_SUBREG (XXPERMDI $src, $src, 3), sub_64)))>;
4260 def : Pat<(f128 (uint_to_fp (i64 (extractelt v2i64:$src, 0)))),
4261 (f128 (XSCVUDQP (COPY_TO_REGCLASS $src, VFRC)))>;
4262 def : Pat<(f128 (uint_to_fp (i64 (extractelt v2i64:$src, 1)))),
4264 (EXTRACT_SUBREG (XXPERMDI $src, $src, 3), sub_64)))>;
4266 // (Un)Signed Word vector extract -> QP
4267 def : Pat<(f128 (sint_to_fp (i32 (extractelt v4i32:$src, 1)))),
4268 (f128 (XSCVSDQP (EXTRACT_SUBREG (VEXTSW2D $src), sub_64)))>;
4269 foreach Idx = [0,2,3] in {
4270 def : Pat<(f128 (sint_to_fp (i32 (extractelt v4i32:$src, Idx)))),
4271 (f128 (XSCVSDQP (EXTRACT_SUBREG
4272 (VEXTSW2D (VSPLTW Idx, $src)), sub_64)))>;
4274 foreach Idx = 0-3 in {
4275 def : Pat<(f128 (uint_to_fp (i32 (extractelt v4i32:$src, Idx)))),
4276 (f128 (XSCVUDQP (XXEXTRACTUW $src, !shl(Idx, 2))))>;
4279 // (Un)Signed HWord vector extract -> QP/DP/SP
4280 foreach Idx = 0-7 in {
4281 def : Pat<(f128 (sint_to_fp
4283 (vector_extract v8i16:$src, Idx), i16)))),
4284 (f128 (XSCVSDQP (EXTRACT_SUBREG
4285 (VEXTSH2D (VEXTRACTUH !add(Idx, Idx), $src)),
4287 // The SDAG adds the `and` since an `i16` is being extracted as an `i32`.
4288 def : Pat<(f128 (uint_to_fp
4289 (and (i32 (vector_extract v8i16:$src, Idx)), 65535))),
4290 (f128 (XSCVUDQP (EXTRACT_SUBREG
4291 (VEXTRACTUH !add(Idx, Idx), $src), sub_64)))>;
4292 def : Pat<(f32 (PPCfcfidus
4293 (f64 (PPCmtvsrz (and (i32 (vector_extract v8i16:$src, Idx)),
4295 (f32 (XSCVUXDSP (EXTRACT_SUBREG
4296 (VEXTRACTUH !add(Idx, Idx), $src), sub_64)))>;
4297 def : Pat<(f32 (PPCfcfids
4299 (i32 (sext_inreg (vector_extract v8i16:$src, Idx),
4301 (f32 (XSCVSXDSP (EXTRACT_SUBREG
4302 (VEXTSH2D (VEXTRACTUH !add(Idx, Idx), $src)),
4304 def : Pat<(f64 (PPCfcfidu
4306 (and (i32 (vector_extract v8i16:$src, Idx)),
4308 (f64 (XSCVUXDDP (EXTRACT_SUBREG
4309 (VEXTRACTUH !add(Idx, Idx), $src), sub_64)))>;
4310 def : Pat<(f64 (PPCfcfid
4312 (i32 (sext_inreg (vector_extract v8i16:$src, Idx),
4314 (f64 (XSCVSXDDP (EXTRACT_SUBREG
4315 (VEXTSH2D (VEXTRACTUH !add(Idx, Idx), $src)),
4319 // (Un)Signed Byte vector extract -> QP
4320 foreach Idx = 0-15 in {
4321 def : Pat<(f128 (sint_to_fp
4322 (i32 (sext_inreg (vector_extract v16i8:$src, Idx),
4324 (f128 (XSCVSDQP (EXTRACT_SUBREG
4325 (VEXTSB2D (VEXTRACTUB Idx, $src)), sub_64)))>;
4326 def : Pat<(f128 (uint_to_fp
4327 (and (i32 (vector_extract v16i8:$src, Idx)), 255))),
4329 (EXTRACT_SUBREG (VEXTRACTUB Idx, $src), sub_64)))>;
4331 def : Pat<(f32 (PPCfcfidus
4333 (and (i32 (vector_extract v16i8:$src, Idx)),
4335 (f32 (XSCVUXDSP (EXTRACT_SUBREG
4336 (VEXTRACTUB !add(Idx, Idx), $src), sub_64)))>;
4337 def : Pat<(f32 (PPCfcfids
4339 (i32 (sext_inreg (vector_extract v16i8:$src, Idx),
4341 (f32 (XSCVSXDSP (EXTRACT_SUBREG
4342 (VEXTSH2D (VEXTRACTUB !add(Idx, Idx), $src)),
4344 def : Pat<(f64 (PPCfcfidu
4346 (and (i32 (vector_extract v16i8:$src, Idx)),
4348 (f64 (XSCVUXDDP (EXTRACT_SUBREG
4349 (VEXTRACTUB !add(Idx, Idx), $src), sub_64)))>;
4350 def : Pat<(f64 (PPCfcfid
4352 (i32 (sext_inreg (vector_extract v16i8:$src, Idx),
4354 (f64 (XSCVSXDDP (EXTRACT_SUBREG
4355 (VEXTSH2D (VEXTRACTUB !add(Idx, Idx), $src)),
4359 // Unsiged int in vsx register -> QP
4360 def : Pat<(f128 (uint_to_fp (i32 (PPCmfvsr f64:$src)))),
4362 (XXEXTRACTUW (SUBREG_TO_REG (i64 1), $src, sub_64), 4)))>;
4363 } // HasVSX, HasP9Vector, IsBigEndian, IsPPC64
4365 // Little endian Power9 subtarget.
4366 let Predicates = [HasVSX, HasP9Vector, IsLittleEndian] in {
4367 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 0)))))),
4368 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 12)))>;
4369 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 1)))))),
4370 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 8)))>;
4371 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 2)))))),
4372 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 4)))>;
4373 def : Pat<(f32 (PPCfcfidus (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 3)))))),
4374 (f32 (XSCVUXDSP (XXEXTRACTUW $A, 0)))>;
4375 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 0)))))),
4376 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 12)))>;
4377 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 1)))))),
4378 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 8)))>;
4379 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 2)))))),
4380 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 4)))>;
4381 def : Pat<(f64 (PPCfcfidu (f64 (PPCmtvsrz (i32 (extractelt v4i32:$A, 3)))))),
4382 (f64 (XSCVUXDDP (XXEXTRACTUW $A, 0)))>;
4383 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 0)),
4384 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 12))>;
4385 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 1)),
4386 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 8))>;
4387 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 2)),
4388 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 4))>;
4389 def : Pat<(v4i32 (insertelt v4i32:$A, i32:$B, 3)),
4390 (v4i32 (XXINSERTW v4i32:$A, AlignValues.I32_TO_BE_WORD1, 0))>;
4391 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 0)),
4392 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 12))>;
4393 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 1)),
4394 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 8))>;
4395 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 2)),
4396 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 4))>;
4397 def : Pat<(v4f32 (insertelt v4f32:$A, f32:$B, 3)),
4398 (v4f32 (XXINSERTW v4f32:$A, AlignValues.F32_TO_BE_WORD1, 0))>;
4400 def : Pat<(v4f32 (insertelt v4f32:$A, (f32 (fpround f64:$B)), 0)),
4401 (v4f32 (XXINSERTW v4f32:$A,
4402 (SUBREG_TO_REG (i64 1), (XSCVDPSP f64:$B), sub_64), 12))>;
4403 def : Pat<(v4f32 (insertelt v4f32:$A, (f32 (fpround f64:$B)), 1)),
4404 (v4f32 (XXINSERTW v4f32:$A,
4405 (SUBREG_TO_REG (i64 1), (XSCVDPSP f64:$B), sub_64), 8))>;
4406 def : Pat<(v4f32 (insertelt v4f32:$A, (f32 (fpround f64:$B)), 2)),
4407 (v4f32 (XXINSERTW v4f32:$A,
4408 (SUBREG_TO_REG (i64 1), (XSCVDPSP f64:$B), sub_64), 4))>;
4409 def : Pat<(v4f32 (insertelt v4f32:$A, (f32 (fpround f64:$B)), 3)),
4410 (v4f32 (XXINSERTW v4f32:$A,
4411 (SUBREG_TO_REG (i64 1), (XSCVDPSP f64:$B), sub_64), 0))>;
4413 def : Pat<(v8i16 (PPCld_vec_be ForceXForm:$src)),
4414 (COPY_TO_REGCLASS (LXVH8X ForceXForm:$src), VRRC)>;
4415 def : Pat<(PPCst_vec_be v8i16:$rS, ForceXForm:$dst),
4416 (STXVH8X (COPY_TO_REGCLASS $rS, VSRC), ForceXForm:$dst)>;
4418 def : Pat<(v16i8 (PPCld_vec_be ForceXForm:$src)),
4419 (COPY_TO_REGCLASS (LXVB16X ForceXForm:$src), VRRC)>;
4420 def : Pat<(PPCst_vec_be v16i8:$rS, ForceXForm:$dst),
4421 (STXVB16X (COPY_TO_REGCLASS $rS, VSRC), ForceXForm:$dst)>;
4423 // Scalar stores of i8
4424 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 0)), ForceXForm:$dst),
4425 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 8)), VSRC), ForceXForm:$dst)>;
4426 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 1)), ForceXForm:$dst),
4427 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 7)), VSRC), ForceXForm:$dst)>;
4428 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 2)), ForceXForm:$dst),
4429 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 6)), VSRC), ForceXForm:$dst)>;
4430 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 3)), ForceXForm:$dst),
4431 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 5)), VSRC), ForceXForm:$dst)>;
4432 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 4)), ForceXForm:$dst),
4433 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 4)), VSRC), ForceXForm:$dst)>;
4434 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 5)), ForceXForm:$dst),
4435 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 3)), VSRC), ForceXForm:$dst)>;
4436 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 6)), ForceXForm:$dst),
4437 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 2)), VSRC), ForceXForm:$dst)>;
4438 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 7)), ForceXForm:$dst),
4439 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 1)), VSRC), ForceXForm:$dst)>;
4440 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 8)), ForceXForm:$dst),
4441 (STXSIBXv (COPY_TO_REGCLASS $S, VSRC), ForceXForm:$dst)>;
4442 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 9)), ForceXForm:$dst),
4443 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 15)), VSRC), ForceXForm:$dst)>;
4444 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 10)), ForceXForm:$dst),
4445 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 14)), VSRC), ForceXForm:$dst)>;
4446 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 11)), ForceXForm:$dst),
4447 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 13)), VSRC), ForceXForm:$dst)>;
4448 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 12)), ForceXForm:$dst),
4449 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 12)), VSRC), ForceXForm:$dst)>;
4450 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 13)), ForceXForm:$dst),
4451 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 11)), VSRC), ForceXForm:$dst)>;
4452 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 14)), ForceXForm:$dst),
4453 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 10)), VSRC), ForceXForm:$dst)>;
4454 def : Pat<(truncstorei8 (i32 (vector_extract v16i8:$S, 15)), ForceXForm:$dst),
4455 (STXSIBXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 9)), VSRC), ForceXForm:$dst)>;
4457 // Scalar stores of i16
4458 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 0)), ForceXForm:$dst),
4459 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 8)), VSRC), ForceXForm:$dst)>;
4460 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 1)), ForceXForm:$dst),
4461 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 6)), VSRC), ForceXForm:$dst)>;
4462 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 2)), ForceXForm:$dst),
4463 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 4)), VSRC), ForceXForm:$dst)>;
4464 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 3)), ForceXForm:$dst),
4465 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 2)), VSRC), ForceXForm:$dst)>;
4466 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 4)), ForceXForm:$dst),
4467 (STXSIHXv (COPY_TO_REGCLASS $S, VSRC), ForceXForm:$dst)>;
4468 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 5)), ForceXForm:$dst),
4469 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 14)), VSRC), ForceXForm:$dst)>;
4470 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 6)), ForceXForm:$dst),
4471 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 12)), VSRC), ForceXForm:$dst)>;
4472 def : Pat<(truncstorei16 (i32 (vector_extract v8i16:$S, 7)), ForceXForm:$dst),
4473 (STXSIHXv (COPY_TO_REGCLASS (v16i8 (VSLDOI $S, $S, 10)), VSRC), ForceXForm:$dst)>;
4475 defm : ScalToVecWPermute<
4476 v2i64, (i64 (load DSForm:$src)),
4477 (XXPERMDIs (DFLOADf64 DSForm:$src), 2),
4478 (SUBREG_TO_REG (i64 1), (DFLOADf64 DSForm:$src), sub_64)>;
4479 defm : ScalToVecWPermute<
4480 v2i64, (i64 (load XForm:$src)),
4481 (XXPERMDIs (XFLOADf64 XForm:$src), 2),
4482 (SUBREG_TO_REG (i64 1), (XFLOADf64 XForm:$src), sub_64)>;
4483 defm : ScalToVecWPermute<
4484 v2f64, (f64 (load DSForm:$src)),
4485 (XXPERMDIs (DFLOADf64 DSForm:$src), 2),
4486 (SUBREG_TO_REG (i64 1), (DFLOADf64 DSForm:$src), sub_64)>;
4487 defm : ScalToVecWPermute<
4488 v2f64, (f64 (load XForm:$src)),
4489 (XXPERMDIs (XFLOADf64 XForm:$src), 2),
4490 (SUBREG_TO_REG (i64 1), (XFLOADf64 XForm:$src), sub_64)>;
4492 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), XForm:$src),
4493 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
4494 sub_64), XForm:$src)>;
4495 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), XForm:$src),
4496 (XFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
4497 sub_64), XForm:$src)>;
4498 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), XForm:$src),
4499 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), XForm:$src)>;
4500 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), XForm:$src),
4501 (XFSTOREf64 (EXTRACT_SUBREG $A, sub_64), XForm:$src)>;
4502 def : Pat<(store (i64 (extractelt v2i64:$A, 0)), DSForm:$src),
4503 (DFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2),
4504 sub_64), DSForm:$src)>;
4505 def : Pat<(store (f64 (extractelt v2f64:$A, 0)), DSForm:$src),
4506 (DFSTOREf64 (EXTRACT_SUBREG (XXPERMDI $A, $A, 2), sub_64),
4508 def : Pat<(store (i64 (extractelt v2i64:$A, 1)), DSForm:$src),
4509 (DFSTOREf64 (EXTRACT_SUBREG $A, sub_64), DSForm:$src)>;
4510 def : Pat<(store (f64 (extractelt v2f64:$A, 1)), DSForm:$src),
4511 (DFSTOREf64 (EXTRACT_SUBREG $A, sub_64), DSForm:$src)>;
4513 // (Un)Signed DWord vector extract -> QP
4514 def : Pat<(f128 (sint_to_fp (i64 (extractelt v2i64:$src, 0)))),
4516 (EXTRACT_SUBREG (XXPERMDI $src, $src, 3), sub_64)))>;
4517 def : Pat<(f128 (sint_to_fp (i64 (extractelt v2i64:$src, 1)))),
4518 (f128 (XSCVSDQP (COPY_TO_REGCLASS $src, VFRC)))>;
4519 def : Pat<(f128 (uint_to_fp (i64 (extractelt v2i64:$src, 0)))),
4521 (EXTRACT_SUBREG (XXPERMDI $src, $src, 3), sub_64)))>;
4522 def : Pat<(f128 (uint_to_fp (i64 (extractelt v2i64:$src, 1)))),
4523 (f128 (XSCVUDQP (COPY_TO_REGCLASS $src, VFRC)))>;
4525 // (Un)Signed Word vector extract -> QP
4526 foreach Idx = [[0,3],[1,2],[3,0]] in {
4527 def : Pat<(f128 (sint_to_fp (i32 (extractelt v4i32:$src, !head(Idx))))),
4528 (f128 (XSCVSDQP (EXTRACT_SUBREG
4529 (VEXTSW2D (VSPLTW !head(!tail(Idx)), $src)),
4532 def : Pat<(f128 (sint_to_fp (i32 (extractelt v4i32:$src, 2)))),
4533 (f128 (XSCVSDQP (EXTRACT_SUBREG (VEXTSW2D $src), sub_64)))>;
4535 foreach Idx = [[0,12],[1,8],[2,4],[3,0]] in {
4536 def : Pat<(f128 (uint_to_fp (i32 (extractelt v4i32:$src, !head(Idx))))),
4537 (f128 (XSCVUDQP (XXEXTRACTUW $src, !head(!tail(Idx)))))>;
4540 // (Un)Signed HWord vector extract -> QP/DP/SP
4541 // The Nested foreach lists identifies the vector element and corresponding
4542 // register byte location.
4543 foreach Idx = [[0,14],[1,12],[2,10],[3,8],[4,6],[5,4],[6,2],[7,0]] in {
4544 def : Pat<(f128 (sint_to_fp
4546 (vector_extract v8i16:$src, !head(Idx)), i16)))),
4548 (EXTRACT_SUBREG (VEXTSH2D
4549 (VEXTRACTUH !head(!tail(Idx)), $src)),
4551 def : Pat<(f128 (uint_to_fp
4552 (and (i32 (vector_extract v8i16:$src, !head(Idx))),
4554 (f128 (XSCVUDQP (EXTRACT_SUBREG
4555 (VEXTRACTUH !head(!tail(Idx)), $src), sub_64)))>;
4556 def : Pat<(f32 (PPCfcfidus
4558 (and (i32 (vector_extract v8i16:$src, !head(Idx))),
4560 (f32 (XSCVUXDSP (EXTRACT_SUBREG
4561 (VEXTRACTUH !head(!tail(Idx)), $src), sub_64)))>;
4562 def : Pat<(f32 (PPCfcfids
4564 (i32 (sext_inreg (vector_extract v8i16:$src,
4565 !head(Idx)), i16)))))),
4568 (VEXTSH2D (VEXTRACTUH !head(!tail(Idx)), $src)),
4570 def : Pat<(f64 (PPCfcfidu
4572 (and (i32 (vector_extract v8i16:$src, !head(Idx))),
4574 (f64 (XSCVUXDDP (EXTRACT_SUBREG
4575 (VEXTRACTUH !head(!tail(Idx)), $src), sub_64)))>;
4576 def : Pat<(f64 (PPCfcfid
4579 (vector_extract v8i16:$src, !head(Idx)), i16)))))),
4581 (EXTRACT_SUBREG (VEXTSH2D
4582 (VEXTRACTUH !head(!tail(Idx)), $src)),
4586 // (Un)Signed Byte vector extract -> QP/DP/SP
4587 foreach Idx = [[0,15],[1,14],[2,13],[3,12],[4,11],[5,10],[6,9],[7,8],[8,7],
4588 [9,6],[10,5],[11,4],[12,3],[13,2],[14,1],[15,0]] in {
4589 def : Pat<(f128 (sint_to_fp
4591 (vector_extract v16i8:$src, !head(Idx)), i8)))),
4594 (VEXTSB2D (VEXTRACTUB !head(!tail(Idx)), $src)),
4596 def : Pat<(f128 (uint_to_fp
4597 (and (i32 (vector_extract v16i8:$src, !head(Idx))),
4601 (VEXTRACTUB !head(!tail(Idx)), $src), sub_64)))>;
4603 def : Pat<(f32 (PPCfcfidus
4605 (and (i32 (vector_extract v16i8:$src, !head(Idx))),
4607 (f32 (XSCVUXDSP (EXTRACT_SUBREG
4608 (VEXTRACTUB !head(!tail(Idx)), $src), sub_64)))>;
4609 def : Pat<(f32 (PPCfcfids
4612 (vector_extract v16i8:$src, !head(Idx)), i8)))))),
4614 (EXTRACT_SUBREG (VEXTSH2D
4615 (VEXTRACTUB !head(!tail(Idx)), $src)),
4617 def : Pat<(f64 (PPCfcfidu
4620 (vector_extract v16i8:$src, !head(Idx))), 255))))),
4621 (f64 (XSCVUXDDP (EXTRACT_SUBREG
4622 (VEXTRACTUB !head(!tail(Idx)), $src), sub_64)))>;
4623 def : Pat<(f64 (PPCfcfidu
4626 (vector_extract v16i8:$src, !head(Idx)), i8)))))),
4628 (EXTRACT_SUBREG (VEXTSH2D
4629 (VEXTRACTUB !head(!tail(Idx)), $src)),
4632 def : Pat<(f64 (PPCfcfid
4635 (vector_extract v16i8:$src, !head(Idx)), i8)))))),
4637 (EXTRACT_SUBREG (VEXTSH2D
4638 (VEXTRACTUH !head(!tail(Idx)), $src)),
4642 // Unsiged int in vsx register -> QP
4643 def : Pat<(f128 (uint_to_fp (i32 (PPCmfvsr f64:$src)))),
4645 (XXEXTRACTUW (SUBREG_TO_REG (i64 1), $src, sub_64), 8)))>;
4646 } // HasVSX, HasP9Vector, IsLittleEndian
4648 // Any Power9 VSX subtarget that supports Power9 Altivec.
4649 let Predicates = [HasVSX, HasP9Altivec] in {
4650 // Put this P9Altivec related definition here since it's possible to be
4651 // selected to VSX instruction xvnegsp, avoid possible undef.
4652 def : Pat<(v4i32 (PPCvabsd v4i32:$A, v4i32:$B, (i32 0))),
4653 (v4i32 (VABSDUW $A, $B))>;
4655 def : Pat<(v8i16 (PPCvabsd v8i16:$A, v8i16:$B, (i32 0))),
4656 (v8i16 (VABSDUH $A, $B))>;
4658 def : Pat<(v16i8 (PPCvabsd v16i8:$A, v16i8:$B, (i32 0))),
4659 (v16i8 (VABSDUB $A, $B))>;
4661 // As PPCVABSD description, the last operand indicates whether do the
4663 def : Pat<(v4i32 (PPCvabsd v4i32:$A, v4i32:$B, (i32 1))),
4664 (v4i32 (VABSDUW (XVNEGSP $A), (XVNEGSP $B)))>;
4665 } // HasVSX, HasP9Altivec
4667 // Big endian Power9 64Bit VSX subtargets with P9 Altivec support.
4668 let Predicates = [HasVSX, HasP9Altivec, IsBigEndian, IsPPC64] in {
4669 def : Pat<(i64 (anyext (i32 (vector_extract v16i8:$S, i64:$Idx)))),
4670 (VEXTUBLX $Idx, $S)>;
4672 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, i64:$Idx)))),
4673 (VEXTUHLX (RLWINM8 $Idx, 1, 28, 30), $S)>;
4674 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 0)))),
4675 (VEXTUHLX (LI8 0), $S)>;
4676 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 1)))),
4677 (VEXTUHLX (LI8 2), $S)>;
4678 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 2)))),
4679 (VEXTUHLX (LI8 4), $S)>;
4680 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 3)))),
4681 (VEXTUHLX (LI8 6), $S)>;
4682 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 4)))),
4683 (VEXTUHLX (LI8 8), $S)>;
4684 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 5)))),
4685 (VEXTUHLX (LI8 10), $S)>;
4686 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 6)))),
4687 (VEXTUHLX (LI8 12), $S)>;
4688 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 7)))),
4689 (VEXTUHLX (LI8 14), $S)>;
4691 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, i64:$Idx)))),
4692 (VEXTUWLX (RLWINM8 $Idx, 2, 28, 29), $S)>;
4693 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 0)))),
4694 (VEXTUWLX (LI8 0), $S)>;
4696 // For extracting BE word 1, MFVSRWZ is better than VEXTUWLX
4697 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 1)))),
4698 (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
4699 (i32 VectorExtractions.LE_WORD_2), sub_32)>;
4700 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 2)))),
4701 (VEXTUWLX (LI8 8), $S)>;
4702 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 3)))),
4703 (VEXTUWLX (LI8 12), $S)>;
4705 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, i64:$Idx)))),
4706 (EXTSW (VEXTUWLX (RLWINM8 $Idx, 2, 28, 29), $S))>;
4707 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 0)))),
4708 (EXTSW (VEXTUWLX (LI8 0), $S))>;
4709 // For extracting BE word 1, MFVSRWZ is better than VEXTUWLX
4710 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 1)))),
4711 (EXTSW (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
4712 (i32 VectorExtractions.LE_WORD_2), sub_32))>;
4713 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 2)))),
4714 (EXTSW (VEXTUWLX (LI8 8), $S))>;
4715 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 3)))),
4716 (EXTSW (VEXTUWLX (LI8 12), $S))>;
4718 def : Pat<(i32 (vector_extract v16i8:$S, i64:$Idx)),
4719 (i32 (EXTRACT_SUBREG (VEXTUBLX $Idx, $S), sub_32))>;
4720 def : Pat<(i32 (vector_extract v16i8:$S, 0)),
4721 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 0), $S), sub_32))>;
4722 def : Pat<(i32 (vector_extract v16i8:$S, 1)),
4723 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 1), $S), sub_32))>;
4724 def : Pat<(i32 (vector_extract v16i8:$S, 2)),
4725 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 2), $S), sub_32))>;
4726 def : Pat<(i32 (vector_extract v16i8:$S, 3)),
4727 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 3), $S), sub_32))>;
4728 def : Pat<(i32 (vector_extract v16i8:$S, 4)),
4729 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 4), $S), sub_32))>;
4730 def : Pat<(i32 (vector_extract v16i8:$S, 5)),
4731 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 5), $S), sub_32))>;
4732 def : Pat<(i32 (vector_extract v16i8:$S, 6)),
4733 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 6), $S), sub_32))>;
4734 def : Pat<(i32 (vector_extract v16i8:$S, 7)),
4735 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 7), $S), sub_32))>;
4736 def : Pat<(i32 (vector_extract v16i8:$S, 8)),
4737 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 8), $S), sub_32))>;
4738 def : Pat<(i32 (vector_extract v16i8:$S, 9)),
4739 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 9), $S), sub_32))>;
4740 def : Pat<(i32 (vector_extract v16i8:$S, 10)),
4741 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 10), $S), sub_32))>;
4742 def : Pat<(i32 (vector_extract v16i8:$S, 11)),
4743 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 11), $S), sub_32))>;
4744 def : Pat<(i32 (vector_extract v16i8:$S, 12)),
4745 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 12), $S), sub_32))>;
4746 def : Pat<(i32 (vector_extract v16i8:$S, 13)),
4747 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 13), $S), sub_32))>;
4748 def : Pat<(i32 (vector_extract v16i8:$S, 14)),
4749 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 14), $S), sub_32))>;
4750 def : Pat<(i32 (vector_extract v16i8:$S, 15)),
4751 (i32 (EXTRACT_SUBREG (VEXTUBLX (LI8 15), $S), sub_32))>;
4753 def : Pat<(i32 (vector_extract v8i16:$S, i64:$Idx)),
4754 (i32 (EXTRACT_SUBREG (VEXTUHLX
4755 (RLWINM8 $Idx, 1, 28, 30), $S), sub_32))>;
4756 def : Pat<(i32 (vector_extract v8i16:$S, 0)),
4757 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 0), $S), sub_32))>;
4758 def : Pat<(i32 (vector_extract v8i16:$S, 1)),
4759 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 2), $S), sub_32))>;
4760 def : Pat<(i32 (vector_extract v8i16:$S, 2)),
4761 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 4), $S), sub_32))>;
4762 def : Pat<(i32 (vector_extract v8i16:$S, 3)),
4763 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 6), $S), sub_32))>;
4764 def : Pat<(i32 (vector_extract v8i16:$S, 4)),
4765 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 8), $S), sub_32))>;
4766 def : Pat<(i32 (vector_extract v8i16:$S, 5)),
4767 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 10), $S), sub_32))>;
4768 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
4769 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 12), $S), sub_32))>;
4770 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
4771 (i32 (EXTRACT_SUBREG (VEXTUHLX (LI8 14), $S), sub_32))>;
4773 def : Pat<(i32 (vector_extract v4i32:$S, i64:$Idx)),
4774 (i32 (EXTRACT_SUBREG (VEXTUWLX
4775 (RLWINM8 $Idx, 2, 28, 29), $S), sub_32))>;
4776 def : Pat<(i32 (vector_extract v4i32:$S, 0)),
4777 (i32 (EXTRACT_SUBREG (VEXTUWLX (LI8 0), $S), sub_32))>;
4778 // For extracting BE word 1, MFVSRWZ is better than VEXTUWLX
4779 def : Pat<(i32 (vector_extract v4i32:$S, 1)),
4780 (i32 VectorExtractions.LE_WORD_2)>;
4781 def : Pat<(i32 (vector_extract v4i32:$S, 2)),
4782 (i32 (EXTRACT_SUBREG (VEXTUWLX (LI8 8), $S), sub_32))>;
4783 def : Pat<(i32 (vector_extract v4i32:$S, 3)),
4784 (i32 (EXTRACT_SUBREG (VEXTUWLX (LI8 12), $S), sub_32))>;
4786 // P9 Altivec instructions that can be used to build vectors.
4787 // Adding them to PPCInstrVSX.td rather than PPCAltivecVSX.td to compete
4788 // with complexities of existing build vector patterns in this file.
4789 def : Pat<(v2i64 (build_vector WordToDWord.BE_A0, WordToDWord.BE_A1)),
4790 (v2i64 (VEXTSW2D $A))>;
4791 def : Pat<(v2i64 (build_vector HWordToDWord.BE_A0, HWordToDWord.BE_A1)),
4792 (v2i64 (VEXTSH2D $A))>;
4793 def : Pat<(v4i32 (build_vector HWordToWord.BE_A0, HWordToWord.BE_A1,
4794 HWordToWord.BE_A2, HWordToWord.BE_A3)),
4795 (v4i32 (VEXTSH2W $A))>;
4796 def : Pat<(v4i32 (build_vector ByteToWord.BE_A0, ByteToWord.BE_A1,
4797 ByteToWord.BE_A2, ByteToWord.BE_A3)),
4798 (v4i32 (VEXTSB2W $A))>;
4799 def : Pat<(v2i64 (build_vector ByteToDWord.BE_A0, ByteToDWord.BE_A1)),
4800 (v2i64 (VEXTSB2D $A))>;
4801 } // HasVSX, HasP9Altivec, IsBigEndian, IsPPC64
4803 // Little endian Power9 VSX subtargets with P9 Altivec support.
4804 let Predicates = [HasVSX, HasP9Altivec, IsLittleEndian] in {
4805 def : Pat<(i64 (anyext (i32 (vector_extract v16i8:$S, i64:$Idx)))),
4806 (VEXTUBRX $Idx, $S)>;
4808 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, i64:$Idx)))),
4809 (VEXTUHRX (RLWINM8 $Idx, 1, 28, 30), $S)>;
4810 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 0)))),
4811 (VEXTUHRX (LI8 0), $S)>;
4812 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 1)))),
4813 (VEXTUHRX (LI8 2), $S)>;
4814 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 2)))),
4815 (VEXTUHRX (LI8 4), $S)>;
4816 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 3)))),
4817 (VEXTUHRX (LI8 6), $S)>;
4818 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 4)))),
4819 (VEXTUHRX (LI8 8), $S)>;
4820 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 5)))),
4821 (VEXTUHRX (LI8 10), $S)>;
4822 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 6)))),
4823 (VEXTUHRX (LI8 12), $S)>;
4824 def : Pat<(i64 (anyext (i32 (vector_extract v8i16:$S, 7)))),
4825 (VEXTUHRX (LI8 14), $S)>;
4827 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, i64:$Idx)))),
4828 (VEXTUWRX (RLWINM8 $Idx, 2, 28, 29), $S)>;
4829 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 0)))),
4830 (VEXTUWRX (LI8 0), $S)>;
4831 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 1)))),
4832 (VEXTUWRX (LI8 4), $S)>;
4833 // For extracting LE word 2, MFVSRWZ is better than VEXTUWRX
4834 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 2)))),
4835 (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
4836 (i32 VectorExtractions.LE_WORD_2), sub_32)>;
4837 def : Pat<(i64 (zext (i32 (vector_extract v4i32:$S, 3)))),
4838 (VEXTUWRX (LI8 12), $S)>;
4840 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, i64:$Idx)))),
4841 (EXTSW (VEXTUWRX (RLWINM8 $Idx, 2, 28, 29), $S))>;
4842 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 0)))),
4843 (EXTSW (VEXTUWRX (LI8 0), $S))>;
4844 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 1)))),
4845 (EXTSW (VEXTUWRX (LI8 4), $S))>;
4846 // For extracting LE word 2, MFVSRWZ is better than VEXTUWRX
4847 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 2)))),
4848 (EXTSW (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
4849 (i32 VectorExtractions.LE_WORD_2), sub_32))>;
4850 def : Pat<(i64 (sext (i32 (vector_extract v4i32:$S, 3)))),
4851 (EXTSW (VEXTUWRX (LI8 12), $S))>;
4853 def : Pat<(i32 (vector_extract v16i8:$S, i64:$Idx)),
4854 (i32 (EXTRACT_SUBREG (VEXTUBRX $Idx, $S), sub_32))>;
4855 def : Pat<(i32 (vector_extract v16i8:$S, 0)),
4856 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 0), $S), sub_32))>;
4857 def : Pat<(i32 (vector_extract v16i8:$S, 1)),
4858 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 1), $S), sub_32))>;
4859 def : Pat<(i32 (vector_extract v16i8:$S, 2)),
4860 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 2), $S), sub_32))>;
4861 def : Pat<(i32 (vector_extract v16i8:$S, 3)),
4862 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 3), $S), sub_32))>;
4863 def : Pat<(i32 (vector_extract v16i8:$S, 4)),
4864 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 4), $S), sub_32))>;
4865 def : Pat<(i32 (vector_extract v16i8:$S, 5)),
4866 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 5), $S), sub_32))>;
4867 def : Pat<(i32 (vector_extract v16i8:$S, 6)),
4868 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 6), $S), sub_32))>;
4869 def : Pat<(i32 (vector_extract v16i8:$S, 7)),
4870 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 7), $S), sub_32))>;
4871 def : Pat<(i32 (vector_extract v16i8:$S, 8)),
4872 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 8), $S), sub_32))>;
4873 def : Pat<(i32 (vector_extract v16i8:$S, 9)),
4874 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 9), $S), sub_32))>;
4875 def : Pat<(i32 (vector_extract v16i8:$S, 10)),
4876 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 10), $S), sub_32))>;
4877 def : Pat<(i32 (vector_extract v16i8:$S, 11)),
4878 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 11), $S), sub_32))>;
4879 def : Pat<(i32 (vector_extract v16i8:$S, 12)),
4880 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 12), $S), sub_32))>;
4881 def : Pat<(i32 (vector_extract v16i8:$S, 13)),
4882 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 13), $S), sub_32))>;
4883 def : Pat<(i32 (vector_extract v16i8:$S, 14)),
4884 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 14), $S), sub_32))>;
4885 def : Pat<(i32 (vector_extract v16i8:$S, 15)),
4886 (i32 (EXTRACT_SUBREG (VEXTUBRX (LI8 15), $S), sub_32))>;
4888 def : Pat<(i32 (vector_extract v8i16:$S, i64:$Idx)),
4889 (i32 (EXTRACT_SUBREG (VEXTUHRX
4890 (RLWINM8 $Idx, 1, 28, 30), $S), sub_32))>;
4891 def : Pat<(i32 (vector_extract v8i16:$S, 0)),
4892 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 0), $S), sub_32))>;
4893 def : Pat<(i32 (vector_extract v8i16:$S, 1)),
4894 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 2), $S), sub_32))>;
4895 def : Pat<(i32 (vector_extract v8i16:$S, 2)),
4896 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 4), $S), sub_32))>;
4897 def : Pat<(i32 (vector_extract v8i16:$S, 3)),
4898 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 6), $S), sub_32))>;
4899 def : Pat<(i32 (vector_extract v8i16:$S, 4)),
4900 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 8), $S), sub_32))>;
4901 def : Pat<(i32 (vector_extract v8i16:$S, 5)),
4902 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 10), $S), sub_32))>;
4903 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
4904 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 12), $S), sub_32))>;
4905 def : Pat<(i32 (vector_extract v8i16:$S, 6)),
4906 (i32 (EXTRACT_SUBREG (VEXTUHRX (LI8 14), $S), sub_32))>;
4908 def : Pat<(i32 (vector_extract v4i32:$S, i64:$Idx)),
4909 (i32 (EXTRACT_SUBREG (VEXTUWRX
4910 (RLWINM8 $Idx, 2, 28, 29), $S), sub_32))>;
4911 def : Pat<(i32 (vector_extract v4i32:$S, 0)),
4912 (i32 (EXTRACT_SUBREG (VEXTUWRX (LI8 0), $S), sub_32))>;
4913 def : Pat<(i32 (vector_extract v4i32:$S, 1)),
4914 (i32 (EXTRACT_SUBREG (VEXTUWRX (LI8 4), $S), sub_32))>;
4915 // For extracting LE word 2, MFVSRWZ is better than VEXTUWRX
4916 def : Pat<(i32 (vector_extract v4i32:$S, 2)),
4917 (i32 VectorExtractions.LE_WORD_2)>;
4918 def : Pat<(i32 (vector_extract v4i32:$S, 3)),
4919 (i32 (EXTRACT_SUBREG (VEXTUWRX (LI8 12), $S), sub_32))>;
4921 // P9 Altivec instructions that can be used to build vectors.
4922 // Adding them to PPCInstrVSX.td rather than PPCAltivecVSX.td to compete
4923 // with complexities of existing build vector patterns in this file.
4924 def : Pat<(v2i64 (build_vector WordToDWord.LE_A0, WordToDWord.LE_A1)),
4925 (v2i64 (VEXTSW2D $A))>;
4926 def : Pat<(v2i64 (build_vector HWordToDWord.LE_A0, HWordToDWord.LE_A1)),
4927 (v2i64 (VEXTSH2D $A))>;
4928 def : Pat<(v4i32 (build_vector HWordToWord.LE_A0, HWordToWord.LE_A1,
4929 HWordToWord.LE_A2, HWordToWord.LE_A3)),
4930 (v4i32 (VEXTSH2W $A))>;
4931 def : Pat<(v4i32 (build_vector ByteToWord.LE_A0, ByteToWord.LE_A1,
4932 ByteToWord.LE_A2, ByteToWord.LE_A3)),
4933 (v4i32 (VEXTSB2W $A))>;
4934 def : Pat<(v2i64 (build_vector ByteToDWord.LE_A0, ByteToDWord.LE_A1)),
4935 (v2i64 (VEXTSB2D $A))>;
4936 } // HasVSX, HasP9Altivec, IsLittleEndian
4938 // Big endian 64Bit VSX subtarget that supports additional direct moves from
4940 let Predicates = [HasVSX, IsISA3_0, HasDirectMove, IsBigEndian, IsPPC64] in {
4941 def : Pat<(i64 (extractelt v2i64:$A, 1)),
4942 (i64 (MFVSRLD $A))>;
4943 // Better way to build integer vectors if we have MTVSRDD. Big endian.
4944 def : Pat<(v2i64 (build_vector i64:$rB, i64:$rA)),
4945 (v2i64 (MTVSRDD $rB, $rA))>;
4946 def : Pat<(v4i32 (build_vector i32:$A, i32:$B, i32:$C, i32:$D)),
4948 (RLDIMI AnyExts.B, AnyExts.A, 32, 0),
4949 (RLDIMI AnyExts.D, AnyExts.C, 32, 0))>;
4951 def : Pat<(f128 (PPCbuild_fp128 i64:$rB, i64:$rA)),
4952 (f128 (COPY_TO_REGCLASS (MTVSRDD $rB, $rA), VRRC))>;
4953 } // HasVSX, IsISA3_0, HasDirectMove, IsBigEndian, IsPPC64
4955 // Little endian VSX subtarget that supports direct moves from ISA3.0.
4956 let Predicates = [HasVSX, IsISA3_0, HasDirectMove, IsLittleEndian] in {
4957 def : Pat<(i64 (extractelt v2i64:$A, 0)),
4958 (i64 (MFVSRLD $A))>;
4959 // Better way to build integer vectors if we have MTVSRDD. Little endian.
4960 def : Pat<(v2i64 (build_vector i64:$rA, i64:$rB)),
4961 (v2i64 (MTVSRDD $rB, $rA))>;
4962 def : Pat<(v4i32 (build_vector i32:$A, i32:$B, i32:$C, i32:$D)),
4964 (RLDIMI AnyExts.C, AnyExts.D, 32, 0),
4965 (RLDIMI AnyExts.A, AnyExts.B, 32, 0))>;
4967 def : Pat<(f128 (PPCbuild_fp128 i64:$rA, i64:$rB)),
4968 (f128 (COPY_TO_REGCLASS (MTVSRDD $rB, $rA), VRRC))>;
4969 } // HasVSX, IsISA3_0, HasDirectMove, IsLittleEndian
4970 } // AddedComplexity = 400
4972 //---------------------------- Instruction aliases ---------------------------//
4973 def : InstAlias<"xvmovdp $XT, $XB",
4974 (XVCPSGNDP vsrc:$XT, vsrc:$XB, vsrc:$XB)>;
4975 def : InstAlias<"xvmovsp $XT, $XB",
4976 (XVCPSGNSP vsrc:$XT, vsrc:$XB, vsrc:$XB)>;
4978 // Certain versions of the AIX assembler may missassemble these mnemonics.
4979 let Predicates = [ModernAs] in {
4980 def : InstAlias<"xxspltd $XT, $XB, 0",
4981 (XXPERMDI vsrc:$XT, vsrc:$XB, vsrc:$XB, 0)>;
4982 def : InstAlias<"xxspltd $XT, $XB, 1",
4983 (XXPERMDI vsrc:$XT, vsrc:$XB, vsrc:$XB, 3)>;
4984 def : InstAlias<"xxspltd $XT, $XB, 0",
4985 (XXPERMDIs vsrc:$XT, vsfrc:$XB, 0)>;
4986 def : InstAlias<"xxspltd $XT, $XB, 1",
4987 (XXPERMDIs vsrc:$XT, vsfrc:$XB, 3)>;
4990 def : InstAlias<"xxmrghd $XT, $XA, $XB",
4991 (XXPERMDI vsrc:$XT, vsrc:$XA, vsrc:$XB, 0)>;
4992 def : InstAlias<"xxmrgld $XT, $XA, $XB",
4993 (XXPERMDI vsrc:$XT, vsrc:$XA, vsrc:$XB, 3)>;
4994 def : InstAlias<"xxswapd $XT, $XB",
4995 (XXPERMDI vsrc:$XT, vsrc:$XB, vsrc:$XB, 2)>;
4996 def : InstAlias<"xxswapd $XT, $XB",
4997 (XXPERMDIs vsrc:$XT, vsfrc:$XB, 2)>;
4998 def : InstAlias<"mfvrd $rA, $XT",
4999 (MFVRD g8rc:$rA, vrrc:$XT), 0>;
5000 def : InstAlias<"mffprd $rA, $src",
5001 (MFVSRD g8rc:$rA, f8rc:$src)>;
5002 def : InstAlias<"mtvrd $XT, $rA",
5003 (MTVRD vrrc:$XT, g8rc:$rA), 0>;
5004 def : InstAlias<"mtfprd $dst, $rA",
5005 (MTVSRD f8rc:$dst, g8rc:$rA)>;
5006 def : InstAlias<"mfvrwz $rA, $XT",
5007 (MFVRWZ gprc:$rA, vrrc:$XT), 0>;
5008 def : InstAlias<"mffprwz $rA, $src",
5009 (MFVSRWZ gprc:$rA, f8rc:$src)>;
5010 def : InstAlias<"mtvrwa $XT, $rA",
5011 (MTVRWA vrrc:$XT, gprc:$rA), 0>;
5012 def : InstAlias<"mtfprwa $dst, $rA",
5013 (MTVSRWA f8rc:$dst, gprc:$rA)>;
5014 def : InstAlias<"mtvrwz $XT, $rA",
5015 (MTVRWZ vrrc:$XT, gprc:$rA), 0>;
5016 def : InstAlias<"mtfprwz $dst, $rA",
5017 (MTVSRWZ f8rc:$dst, gprc:$rA)>;