Path: blob/main/contrib/llvm-project/llvm/lib/Target/Mips/MSA.txt
35269 views
Code Generation Notes for MSA1=============================23Intrinsics are lowered to SelectionDAG nodes where possible in order to enable4optimisation, reduce the size of the ISel matcher, and reduce repetition in5the implementation. In a small number of cases, this can cause different6(semantically equivalent) instructions to be used in place of the requested7instruction, even when no optimisation has taken place.89Instructions10============1112This section describes any quirks of instruction selection for MSA. For13example, two instructions might be equally valid for some given IR and one is14chosen in preference to the other.1516bclri.b:17It is not possible to emit bclri.b since andi.b covers exactly the18same cases. andi.b should use fractionally less power than bclri.b in19most hardware implementations so it is used in preference to bclri.b.2021vshf.w:22It is not possible to emit vshf.w when the shuffle description is23constant since shf.w covers exactly the same cases. shf.w is used24instead. It is also impossible for the shuffle description to be25unknown at compile-time due to the definition of shufflevector in26LLVM IR.2728vshf.[bhwd]29When the shuffle description describes a splat operation, splat.[bhwd]30instructions will be selected instead of vshf.[bhwd]. Unlike the ilv*,31and pck* instructions, this is matched from MipsISD::VSHF instead of32a special-case MipsISD node.3334ilvl.d, pckev.d:35It is not possible to emit ilvl.d, or pckev.d since ilvev.d covers the36same shuffle. ilvev.d will be emitted instead.3738ilvr.d, ilvod.d, pckod.d:39It is not possible to emit ilvr.d, or pckod.d since ilvod.d covers the40same shuffle. ilvod.d will be emitted instead.4142splat.[bhwd]43The intrinsic will work as expected. However, unlike other intrinsics44it lowers directly to MipsISD::VSHF instead of using common IR.4546splati.w:47It is not possible to emit splati.w since shf.w covers the same cases.48shf.w will be emitted instead.4950copy_s.w:51On MIPS32, the copy_u.d intrinsic will emit this instruction instead of52copy_u.w. This is semantically equivalent since the general-purpose53register file is 32-bits wide.5455binsri.[bhwd], binsli.[bhwd]:56These two operations are equivalent to each other with the operands57swapped and condition inverted. The compiler may use either one as58appropriate.59Furthermore, the compiler may use bsel.[bhwd] for some masks that do60not survive the legalization process (this is a bug and will be fixed).6162bmnz.v, bmz.v, bsel.v:63These three operations differ only in the operand that is tied to the64result and the order of the operands.65It is (currently) not possible to emit bmz.v, or bsel.v since bmnz.v is66the same operation and will be emitted instead.67In future, the compiler may choose between these three instructions68according to register allocation.69These three operations can be very confusing so here is a mapping70between the instructions and the vselect node in one place:71bmz.v wd, ws, wt/i8 -> (vselect wt/i8, wd, ws)72bmnz.v wd, ws, wt/i8 -> (vselect wt/i8, ws, wd)73bsel.v wd, ws, wt/i8 -> (vselect wd, wt/i8, ws)7475bmnzi.b, bmzi.b:76Like their non-immediate counterparts, bmnzi.v and bmzi.v are the same77operation with the operands swapped. bmnzi.v will (currently) be emitted78for both cases.7980bseli.v:81Unlike the non-immediate versions, bseli.v is distinguishable from82bmnzi.b and bmzi.b and can be emitted.838485