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