@@ -4324,11 +4324,11 @@ enum class SrcStatus {
43244324 IS_UPPER_HALF,
43254325 IS_LOWER_HALF,
43264326 IS_UPPER_HALF_NEG,
4327- // This means current op = [op_upper, op_lower] and src = -op_lower
4327+ // This means current op = [op_upper, op_lower] and src = -op_lower.
43284328 IS_LOWER_HALF_NEG,
43294329 IS_HI_NEG,
43304330 // This means current op = [op_upper, op_lower] and src = [op_upper,
4331- // -op_lower]
4331+ // -op_lower].
43324332 IS_LO_NEG,
43334333 IS_BOTH_NEG,
43344334 INVALID,
@@ -4548,8 +4548,9 @@ static SrcStatus getNegStatus(const MachineOperand *Op, SrcStatus S,
45484548 return SrcStatus::IS_LOWER_HALF_NEG;
45494549 }
45504550 break ;
4551+ default :
4552+ llvm_unreachable (" unexpected SrcStatus" );
45514553 }
4552- llvm_unreachable (" unexpected SrcStatus" );
45534554}
45544555
45554556static std::optional<std::pair<const MachineOperand *, SrcStatus>>
@@ -4558,15 +4559,9 @@ calcNextStatus(std::pair<const MachineOperand *, SrcStatus> Curr,
45584559 if (!Curr.first ->isReg ())
45594560 return std::nullopt ;
45604561
4561- const MachineInstr *MI = nullptr ;
4562-
4563- if (!Curr.first ->isDef ())
4564- MI = MRI.getVRegDef (Curr.first ->getReg ());
4565- else
4566- MI = Curr.first ->getParent ();
4567-
4568- if (!MI)
4569- return std::nullopt ;
4562+ const MachineInstr *MI = Curr.first ->isDef ()
4563+ ? Curr.first ->getParent ()
4564+ : MRI.getVRegDef (Curr.first ->getReg ());
45704565
45714566 unsigned Opc = MI->getOpcode ();
45724567
@@ -4626,7 +4621,7 @@ calcNextStatus(std::pair<const MachineOperand *, SrcStatus> Curr,
46264621class searchOptions {
46274622private:
46284623 bool HasNeg = false ;
4629- // Assume all complex pattern of VOP3P has opsel
4624+ // Assume all complex pattern of VOP3P has opsel.
46304625 bool HasOpsel = true ;
46314626
46324627public:
@@ -4635,11 +4630,11 @@ class searchOptions {
46354630 unsigned Opc = MI->getOpcode ();
46364631
46374632 if (Opc < TargetOpcode::GENERIC_OP_END) {
4638- // Keep same for generic op
4633+ // Keep same for generic op.
46394634 HasNeg = true ;
46404635 } else if (Opc == TargetOpcode::G_INTRINSIC) {
46414636 Intrinsic::ID IntrinsicID = cast<GIntrinsic>(*MI).getIntrinsicID ();
4642- // Only float point intrinsic has neg & neg_hi bits
4637+ // Only float point intrinsic has neg & neg_hi bits.
46434638 if (IntrinsicID == Intrinsic::amdgcn_fdot2)
46444639 HasNeg = true ;
46454640 }
@@ -4666,9 +4661,8 @@ getSrcStats(const MachineOperand *Op, const MachineRegisterInfo &MRI,
46664661
46674662 while (Depth <= MaxDepth && Curr.has_value ()) {
46684663 Depth++;
4669- if (SearchOptions.checkOptions (Curr.value ().second )) {
4664+ if (SearchOptions.checkOptions (Curr.value ().second ))
46704665 Statlist.push_back (Curr.value ());
4671- }
46724666 Curr = calcNextStatus (Curr.value (), MRI);
46734667 }
46744668
@@ -4712,9 +4706,9 @@ static bool isSameBitWidth(const MachineOperand *Op1, const MachineOperand *Op2,
47124706
47134707static bool isSameOperand (const MachineOperand *Op1,
47144708 const MachineOperand *Op2) {
4715- if (Op1->isReg ()) {
4709+ if (Op1->isReg ())
47164710 return Op2->isReg () && Op1->getReg () == Op2->getReg ();
4717- }
4711+
47184712 return Op1->isIdenticalTo (*Op2);
47194713}
47204714
@@ -4769,7 +4763,7 @@ AMDGPUInstructionSelector::selectVOP3PModsImpl(const MachineOperand *RootOp,
47694763 bool IsDOT) const {
47704764 unsigned Mods = 0 ;
47714765 const MachineOperand *Op = RootOp;
4772- // No modification if Root type is not form of <2 x Type>
4766+ // No modification if Root type is not form of <2 x Type>.
47734767 if (isVectorOfTwoOrScalar (Op, MRI) != TypeClass::VECTOR_OF_TWO) {
47744768 Mods |= SISrcMods::OP_SEL_1;
47754769 return {Op, Mods};
@@ -4815,13 +4809,13 @@ AMDGPUInstructionSelector::selectVOP3PModsImpl(const MachineOperand *RootOp,
48154809 return {Op, Mods};
48164810 }
48174811
4818- for (int i = StatlistHi.size () - 1 ; i >= 0 ; i --) {
4819- for (int j = StatlistLo.size () - 1 ; j >= 0 ; j --) {
4820- if (isSameOperand (StatlistHi[i ].first , StatlistLo[j ].first ) &&
4821- isValidToPack (StatlistHi[i ].second , StatlistLo[j ].second ,
4822- StatlistHi[i ].first , RootOp, TII, MRI))
4823- return {StatlistHi[i ].first ,
4824- updateMods (StatlistHi[i ].second , StatlistLo[j ].second , Mods)};
4812+ for (int I = StatlistHi.size () - 1 ; I >= 0 ; I --) {
4813+ for (int J = StatlistLo.size () - 1 ; J >= 0 ; J --) {
4814+ if (isSameOperand (StatlistHi[I ].first , StatlistLo[J ].first ) &&
4815+ isValidToPack (StatlistHi[I ].second , StatlistLo[J ].second ,
4816+ StatlistHi[I ].first , RootOp, TII, MRI))
4817+ return {StatlistHi[I ].first ,
4818+ updateMods (StatlistHi[I ].second , StatlistLo[J ].second , Mods)};
48254819 }
48264820 }
48274821 // Packed instructions do not have abs modifiers.
@@ -4851,18 +4845,18 @@ static bool checkRB(const MachineOperand *Op, unsigned int RBNo,
48514845 return RB->getID () == RBNo;
48524846}
48534847
4854- // This function is used to get the correct register bank for returned reg
4848+ // This function is used to get the correct register bank for returned reg.
48554849// Assume:
4856- // 1. VOP3P is always legal for VGPR
4857- // 2. RootOp's regbank is legal
4850+ // 1. VOP3P is always legal for VGPR.
4851+ // 2. RootOp's regbank is legal.
48584852// Thus
4859- // 1. If RootOp is SGPR, then NewOp can be SGPR or VGPR
4860- // 2. If RootOp is VGPR, then NewOp must be VGPR
4853+ // 1. If RootOp is SGPR, then NewOp can be SGPR or VGPR.
4854+ // 2. If RootOp is VGPR, then NewOp must be VGPR.
48614855static const MachineOperand *
48624856getLegalRegBank (const MachineOperand *NewOp, const MachineOperand *RootOp,
48634857 const AMDGPURegisterBankInfo &RBI, MachineRegisterInfo &MRI,
48644858 const TargetRegisterInfo &TRI, const SIInstrInfo &TII) {
4865- // RootOp can only be VGPR or SGPR (some hand written cases such as
4859+ // RootOp can only be VGPR or SGPR (some hand written cases such as.
48664860 // inst-select-ashr.v2s16.mir::ashr_v2s16_vs).
48674861 if (checkRB (RootOp, AMDGPU::SGPRRegBankID, RBI, MRI, TRI) ||
48684862 checkRB (NewOp, AMDGPU::VGPRRegBankID, RBI, MRI, TRI))
@@ -4884,7 +4878,7 @@ getLegalRegBank(const MachineOperand *NewOp, const MachineOperand *RootOp,
48844878 BuildMI (*BB, MI, MI->getDebugLoc (), TII.get (AMDGPU::COPY), DstReg)
48854879 .addReg (NewOp->getReg ());
48864880
4887- // only accept VGPR
4881+ // only accept VGPR.
48884882 return &MIB->getOperand (0 );
48894883}
48904884
0 commit comments