PPCInstrVSX.td 250 KB

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