-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[RISCV] Make more vector pseudos commutable #88379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2127,8 +2127,9 @@ multiclass VPseudoBinary<VReg RetClass, | |
| LMULInfo MInfo, | ||
| string Constraint = "", | ||
| int sew = 0, | ||
| int TargetConstraintType = 1> { | ||
| let VLMul = MInfo.value, SEW=sew in { | ||
| int TargetConstraintType = 1, | ||
| bit Commutable = 0> { | ||
| let VLMul = MInfo.value, SEW=sew, isCommutable = Commutable in { | ||
| defvar suffix = !if(sew, "_" # MInfo.MX # "_E" # sew, "_" # MInfo.MX); | ||
| def suffix : VPseudoBinaryNoMaskTU<RetClass, Op1Class, Op2Class, | ||
| Constraint, TargetConstraintType>; | ||
|
|
@@ -2167,8 +2168,9 @@ multiclass VPseudoBinaryM<VReg RetClass, | |
| DAGOperand Op2Class, | ||
| LMULInfo MInfo, | ||
| string Constraint = "", | ||
| int TargetConstraintType = 1> { | ||
| let VLMul = MInfo.value in { | ||
| int TargetConstraintType = 1, | ||
| bit Commutable = 0> { | ||
| let VLMul = MInfo.value, isCommutable = Commutable in { | ||
| def "_" # MInfo.MX : VPseudoBinaryMOutNoMask<RetClass, Op1Class, Op2Class, | ||
| Constraint, TargetConstraintType>; | ||
| let ForceTailAgnostic = true in | ||
|
|
@@ -2226,8 +2228,8 @@ multiclass VPseudoTiedBinaryRoundingMode<VReg RetClass, | |
| } | ||
|
|
||
|
|
||
| multiclass VPseudoBinaryV_VV<LMULInfo m, string Constraint = "", int sew = 0> { | ||
| defm _VV : VPseudoBinary<m.vrclass, m.vrclass, m.vrclass, m, Constraint, sew>; | ||
| multiclass VPseudoBinaryV_VV<LMULInfo m, string Constraint = "", int sew = 0, bit Commutable = 0> { | ||
| defm _VV : VPseudoBinary<m.vrclass, m.vrclass, m.vrclass, m, Constraint, sew, Commutable=Commutable>; | ||
| } | ||
|
|
||
| multiclass VPseudoBinaryV_VV_RM<LMULInfo m, string Constraint = ""> { | ||
|
|
@@ -2331,9 +2333,10 @@ multiclass VPseudoVALU_MM<bit Commutable = 0> { | |
| // * The destination EEW is greater than the source EEW, the source EMUL is | ||
| // at least 1, and the overlap is in the highest-numbered part of the | ||
| // destination register group is legal. Otherwise, it is illegal. | ||
| multiclass VPseudoBinaryW_VV<LMULInfo m> { | ||
| multiclass VPseudoBinaryW_VV<LMULInfo m, bit Commutable = 0> { | ||
| defm _VV : VPseudoBinary<m.wvrclass, m.vrclass, m.vrclass, m, | ||
| "@earlyclobber $rd", TargetConstraintType=3>; | ||
| "@earlyclobber $rd", TargetConstraintType=3, | ||
| Commutable=Commutable>; | ||
| } | ||
|
|
||
| multiclass VPseudoBinaryW_VV_RM<LMULInfo m, int sew = 0> { | ||
|
|
@@ -2453,7 +2456,9 @@ multiclass VPseudoBinaryV_VM<LMULInfo m, bit CarryOut = 0, bit CarryIn = 1, | |
| m.vrclass, m.vrclass, m, CarryIn, Constraint, TargetConstraintType>; | ||
| } | ||
|
|
||
| multiclass VPseudoTiedBinaryV_VM<LMULInfo m, int TargetConstraintType = 1> { | ||
| multiclass VPseudoTiedBinaryV_VM<LMULInfo m, int TargetConstraintType = 1, | ||
| bit Commutable = 0> { | ||
| let isCommutable = Commutable in | ||
| def "_VVM" # "_" # m.MX: | ||
| VPseudoTiedBinaryCarryIn<GetVRegNoV0<m.vrclass>.R, | ||
| m.vrclass, m.vrclass, m, 1, "", | ||
|
|
@@ -2667,9 +2672,11 @@ multiclass PseudoVEXT_VF8 { | |
| // lowest-numbered part of the source register group". | ||
| // With LMUL<=1 the source and dest occupy a single register so any overlap | ||
| // is in the lowest-numbered part. | ||
| multiclass VPseudoBinaryM_VV<LMULInfo m, int TargetConstraintType = 1> { | ||
| multiclass VPseudoBinaryM_VV<LMULInfo m, int TargetConstraintType = 1, | ||
| bit Commutable = 0> { | ||
| defm _VV : VPseudoBinaryM<VR, m.vrclass, m.vrclass, m, | ||
| !if(!ge(m.octuple, 16), "@earlyclobber $rd", ""), TargetConstraintType>; | ||
| !if(!ge(m.octuple, 16), "@earlyclobber $rd", ""), | ||
| TargetConstraintType, Commutable=Commutable>; | ||
| } | ||
|
|
||
| multiclass VPseudoBinaryM_VX<LMULInfo m, int TargetConstraintType = 1> { | ||
|
|
@@ -2751,10 +2758,11 @@ multiclass VPseudoVSSHT_VV_VX_VI_RM<Operand ImmType = simm5, string Constraint = | |
| } | ||
| } | ||
|
|
||
| multiclass VPseudoVALU_VV_VX_VI<Operand ImmType = simm5, string Constraint = ""> { | ||
| multiclass VPseudoVALU_VV_VX_VI<Operand ImmType = simm5, string Constraint = "", | ||
| bit Commutable = 0> { | ||
| foreach m = MxList in { | ||
| defvar mx = m.MX; | ||
| defm "" : VPseudoBinaryV_VV<m, Constraint>, | ||
| defm "" : VPseudoBinaryV_VV<m, Constraint, Commutable=Commutable>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit, I guess we could also wrap the VPsuedoBlahV_VV in isCommutable so we don't need to add the argument to the _VV classes
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it may make sense. I added this argument just to match existed code. |
||
| SchedBinary<"WriteVIALUV", "ReadVIALUV", "ReadVIALUV", mx, | ||
| forceMergeOpRead=true>; | ||
| defm "" : VPseudoBinaryV_VX<m, Constraint>, | ||
|
|
@@ -2804,17 +2812,17 @@ multiclass VPseudoVAALU_VV_VX_RM { | |
| multiclass VPseudoVMINMAX_VV_VX { | ||
| foreach m = MxList in { | ||
| defvar mx = m.MX; | ||
| defm "" : VPseudoBinaryV_VV<m>, | ||
| defm "" : VPseudoBinaryV_VV<m, Commutable=1>, | ||
| SchedBinary<"WriteVIMinMaxV", "ReadVIMinMaxV", "ReadVIMinMaxV", mx>; | ||
| defm "" : VPseudoBinaryV_VX<m>, | ||
| SchedBinary<"WriteVIMinMaxX", "ReadVIMinMaxV", "ReadVIMinMaxX", mx>; | ||
| } | ||
| } | ||
|
|
||
| multiclass VPseudoVMUL_VV_VX { | ||
| multiclass VPseudoVMUL_VV_VX<bit Commutable = 0> { | ||
| foreach m = MxList in { | ||
| defvar mx = m.MX; | ||
| defm "" : VPseudoBinaryV_VV<m>, | ||
| defm "" : VPseudoBinaryV_VV<m, Commutable=Commutable>, | ||
| SchedBinary<"WriteVIMulV", "ReadVIMulV", "ReadVIMulV", mx>; | ||
| defm "" : VPseudoBinaryV_VX<m>, | ||
| SchedBinary<"WriteVIMulX", "ReadVIMulV", "ReadVIMulX", mx>; | ||
|
|
@@ -2964,10 +2972,10 @@ multiclass VPseudoVALU_VX_VI<Operand ImmType = simm5> { | |
| } | ||
| } | ||
|
|
||
| multiclass VPseudoVWALU_VV_VX { | ||
| multiclass VPseudoVWALU_VV_VX<bit Commutable = 0> { | ||
| foreach m = MxListW in { | ||
| defvar mx = m.MX; | ||
| defm "" : VPseudoBinaryW_VV<m>, | ||
| defm "" : VPseudoBinaryW_VV<m, Commutable=Commutable>, | ||
| SchedBinary<"WriteVIWALUV", "ReadVIWALUV", "ReadVIWALUV", mx, | ||
| forceMergeOpRead=true>; | ||
| defm "" : VPseudoBinaryW_VX<m>, | ||
|
|
@@ -2976,10 +2984,10 @@ multiclass VPseudoVWALU_VV_VX { | |
| } | ||
| } | ||
|
|
||
| multiclass VPseudoVWMUL_VV_VX { | ||
| multiclass VPseudoVWMUL_VV_VX<bit Commutable = 0> { | ||
| foreach m = MxListW in { | ||
| defvar mx = m.MX; | ||
| defm "" : VPseudoBinaryW_VV<m>, | ||
| defm "" : VPseudoBinaryW_VV<m, Commutable=Commutable>, | ||
| SchedBinary<"WriteVIWMulV", "ReadVIWMulV", "ReadVIWMulV", mx, | ||
| forceMergeOpRead=true>; | ||
| defm "" : VPseudoBinaryW_VX<m>, | ||
|
|
@@ -3074,7 +3082,7 @@ multiclass VPseudoVMRG_VM_XM_IM { | |
| multiclass VPseudoVCALU_VM_XM_IM { | ||
| foreach m = MxList in { | ||
| defvar mx = m.MX; | ||
| defm "" : VPseudoTiedBinaryV_VM<m>, | ||
| defm "" : VPseudoTiedBinaryV_VM<m, Commutable=1>, | ||
| SchedBinary<"WriteVICALUV", "ReadVICALUV", "ReadVICALUV", mx, | ||
| forceMergeOpRead=true>; | ||
| defm "" : VPseudoTiedBinaryV_XM<m>, | ||
|
|
@@ -3287,10 +3295,10 @@ multiclass VPseudoTernaryV_VF_AAXA_RM<LMULInfo m, FPR_Info f, | |
| sew, Commutable=1>; | ||
| } | ||
|
|
||
| multiclass VPseudoTernaryW_VV<LMULInfo m> { | ||
| multiclass VPseudoTernaryW_VV<LMULInfo m, bit Commutable = 0> { | ||
| defvar constraint = "@earlyclobber $rd"; | ||
| defm _VV : VPseudoTernaryWithPolicy<m.wvrclass, m.vrclass, m.vrclass, m, | ||
| constraint, /*Commutable*/ 0, TargetConstraintType=3>; | ||
| constraint, Commutable=Commutable, TargetConstraintType=3>; | ||
| } | ||
|
|
||
| multiclass VPseudoTernaryW_VV_RM<LMULInfo m, int sew = 0> { | ||
|
|
@@ -3380,10 +3388,10 @@ multiclass VPseudoVSLD_VX_VI<Operand ImmType = simm5, string Constraint = ""> { | |
| } | ||
| } | ||
|
|
||
| multiclass VPseudoVWMAC_VV_VX { | ||
| multiclass VPseudoVWMAC_VV_VX<bit Commutable = 0> { | ||
| foreach m = MxListW in { | ||
| defvar mx = m.MX; | ||
| defm "" : VPseudoTernaryW_VV<m>, | ||
| defm "" : VPseudoTernaryW_VV<m, Commutable=Commutable>, | ||
| SchedTernary<"WriteVIWMulAddV", "ReadVIWMulAddV", "ReadVIWMulAddV", | ||
| "ReadVIWMulAddV", mx>; | ||
| defm "" : VPseudoTernaryW_VX<m>, | ||
|
|
@@ -3436,10 +3444,10 @@ multiclass VPseudoVWMAC_VV_VF_BF_RM { | |
| } | ||
| } | ||
|
|
||
| multiclass VPseudoVCMPM_VV_VX_VI { | ||
| multiclass VPseudoVCMPM_VV_VX_VI<bit Commutable = 0> { | ||
| foreach m = MxList in { | ||
| defvar mx = m.MX; | ||
| defm "" : VPseudoBinaryM_VV<m, TargetConstraintType=2>, | ||
| defm "" : VPseudoBinaryM_VV<m, TargetConstraintType=2, Commutable=Commutable>, | ||
| SchedBinary<"WriteVICmpV", "ReadVICmpV", "ReadVICmpV", mx>; | ||
| defm "" : VPseudoBinaryM_VX<m, TargetConstraintType=2>, | ||
| SchedBinary<"WriteVICmpX", "ReadVICmpV", "ReadVICmpX", mx>; | ||
|
|
@@ -6248,7 +6256,7 @@ defm PseudoVLSEG : VPseudoUSSegLoadFF; | |
| //===----------------------------------------------------------------------===// | ||
| // 11.1. Vector Single-Width Integer Add and Subtract | ||
| //===----------------------------------------------------------------------===// | ||
| defm PseudoVADD : VPseudoVALU_VV_VX_VI; | ||
| defm PseudoVADD : VPseudoVALU_VV_VX_VI<Commutable=1>; | ||
lukel97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| defm PseudoVSUB : VPseudoVALU_VV_VX; | ||
| defm PseudoVRSUB : VPseudoVALU_VX_VI; | ||
|
|
||
|
|
@@ -6313,9 +6321,9 @@ foreach vti = AllIntegerVectors in { | |
| //===----------------------------------------------------------------------===// | ||
| // 11.2. Vector Widening Integer Add/Subtract | ||
| //===----------------------------------------------------------------------===// | ||
| defm PseudoVWADDU : VPseudoVWALU_VV_VX; | ||
| defm PseudoVWADDU : VPseudoVWALU_VV_VX<Commutable=1>; | ||
| defm PseudoVWSUBU : VPseudoVWALU_VV_VX; | ||
| defm PseudoVWADD : VPseudoVWALU_VV_VX; | ||
| defm PseudoVWADD : VPseudoVWALU_VV_VX<Commutable=1>; | ||
| defm PseudoVWSUB : VPseudoVWALU_VV_VX; | ||
| defm PseudoVWADDU : VPseudoVWALU_WV_WX; | ||
lukel97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| defm PseudoVWSUBU : VPseudoVWALU_WV_WX; | ||
|
|
@@ -6346,9 +6354,9 @@ defm PseudoVMSBC : VPseudoVCALUM_V_X<"@earlyclobber $rd">; | |
| //===----------------------------------------------------------------------===// | ||
| // 11.5. Vector Bitwise Logical Instructions | ||
| //===----------------------------------------------------------------------===// | ||
| defm PseudoVAND : VPseudoVALU_VV_VX_VI; | ||
| defm PseudoVOR : VPseudoVALU_VV_VX_VI; | ||
| defm PseudoVXOR : VPseudoVALU_VV_VX_VI; | ||
| defm PseudoVAND : VPseudoVALU_VV_VX_VI<Commutable=1>; | ||
| defm PseudoVOR : VPseudoVALU_VV_VX_VI<Commutable=1>; | ||
| defm PseudoVXOR : VPseudoVALU_VV_VX_VI<Commutable=1>; | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
| // 11.6. Vector Single-Width Bit Shift Instructions | ||
|
|
@@ -6366,8 +6374,8 @@ defm PseudoVNSRA : VPseudoVNSHT_WV_WX_WI; | |
| //===----------------------------------------------------------------------===// | ||
| // 11.8. Vector Integer Comparison Instructions | ||
| //===----------------------------------------------------------------------===// | ||
| defm PseudoVMSEQ : VPseudoVCMPM_VV_VX_VI; | ||
| defm PseudoVMSNE : VPseudoVCMPM_VV_VX_VI; | ||
| defm PseudoVMSEQ : VPseudoVCMPM_VV_VX_VI<Commutable=1>; | ||
| defm PseudoVMSNE : VPseudoVCMPM_VV_VX_VI<Commutable=1>; | ||
| defm PseudoVMSLTU : VPseudoVCMPM_VV_VX; | ||
| defm PseudoVMSLT : VPseudoVCMPM_VV_VX; | ||
| defm PseudoVMSLEU : VPseudoVCMPM_VV_VX_VI; | ||
|
|
@@ -6386,9 +6394,9 @@ defm PseudoVMAX : VPseudoVMINMAX_VV_VX; | |
| //===----------------------------------------------------------------------===// | ||
| // 11.10. Vector Single-Width Integer Multiply Instructions | ||
| //===----------------------------------------------------------------------===// | ||
| defm PseudoVMUL : VPseudoVMUL_VV_VX; | ||
| defm PseudoVMULH : VPseudoVMUL_VV_VX; | ||
| defm PseudoVMULHU : VPseudoVMUL_VV_VX; | ||
| defm PseudoVMUL : VPseudoVMUL_VV_VX<Commutable=1>; | ||
| defm PseudoVMULH : VPseudoVMUL_VV_VX<Commutable=1>; | ||
| defm PseudoVMULHU : VPseudoVMUL_VV_VX<Commutable=1>; | ||
| defm PseudoVMULHSU : VPseudoVMUL_VV_VX; | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
|
|
@@ -6402,8 +6410,8 @@ defm PseudoVREM : VPseudoVDIV_VV_VX; | |
| //===----------------------------------------------------------------------===// | ||
| // 11.12. Vector Widening Integer Multiply Instructions | ||
| //===----------------------------------------------------------------------===// | ||
| defm PseudoVWMUL : VPseudoVWMUL_VV_VX; | ||
| defm PseudoVWMULU : VPseudoVWMUL_VV_VX; | ||
| defm PseudoVWMUL : VPseudoVWMUL_VV_VX<Commutable=1>; | ||
| defm PseudoVWMULU : VPseudoVWMUL_VV_VX<Commutable=1>; | ||
| defm PseudoVWMULSU : VPseudoVWMUL_VV_VX; | ||
|
|
||
| //===----------------------------------------------------------------------===// | ||
|
|
@@ -6417,8 +6425,8 @@ defm PseudoVNMSUB : VPseudoVMAC_VV_VX_AAXA; | |
| //===----------------------------------------------------------------------===// | ||
| // 11.14. Vector Widening Integer Multiply-Add Instructions | ||
| //===----------------------------------------------------------------------===// | ||
| defm PseudoVWMACCU : VPseudoVWMAC_VV_VX; | ||
| defm PseudoVWMACC : VPseudoVWMAC_VV_VX; | ||
| defm PseudoVWMACCU : VPseudoVWMAC_VV_VX<Commutable=1>; | ||
| defm PseudoVWMACC : VPseudoVWMAC_VV_VX<Commutable=1>; | ||
| defm PseudoVWMACCSU : VPseudoVWMAC_VV_VX; | ||
| defm PseudoVWMACCUS : VPseudoVWMAC_VX; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.