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