PPCInstrVSX.td 249 KB

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