diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td index 1a109e01a4b50e..6d21d7f55bc59f 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td @@ -1887,8 +1887,16 @@ multiclass VPseudoTernary { - foreach m = MxList.m in + foreach m = MxList.m in { defm _VV : VPseudoTernary; + + // Add a commutable version for use by IR mul+add. + let isCommutable = 1, ForceTailAgnostic = true, VLMul = m.value in + def "_VV_" # m.MX # "_COMMUTABLE" : VPseudoTernaryNoMask; + } } multiclass VPseudoTernaryV_VX { @@ -1897,15 +1905,28 @@ multiclass VPseudoTernaryV_VX { } multiclass VPseudoTernaryV_VX_AAXA { - foreach m = MxList.m in + foreach m = MxList.m in { defm "_VX" : VPseudoTernary; + + // Add a commutable version for use by IR mul+add. + let isCommutable = 1, ForceTailAgnostic = true, VLMul = m.value in + def "_VX_" # m.MX # "_COMMUTABLE" : + VPseudoTernaryNoMask; + } } multiclass VPseudoTernaryV_VF_AAXA { - foreach m = MxList.m in - foreach f = FPList.fpinfo in + foreach m = MxList.m in { + foreach f = FPList.fpinfo in { defm "_V" # f.FX : VPseudoTernary; + + // Add a commutable version for use by IR mul+add. + let isCommutable = 1, ForceTailAgnostic = true, VLMul = m.value in + def "_V" # f.FX # "_" # m.MX # "_COMMUTABLE" : + VPseudoTernaryNoMask; + } + } } multiclass VPseudoTernaryW_VV { @@ -1936,44 +1957,11 @@ multiclass VPseudoTernaryV_VI { multiclass VPseudoTernaryV_VV_VX_AAXA { defm "" : VPseudoTernaryV_VV; defm "" : VPseudoTernaryV_VX_AAXA; - - foreach m = MxList.m in { - // Add a commutable version for use by IR mul+add. - // NOTE: We need this because we use a tail undisturbed policy on the - // intrinsic version so we can't commute those instructions since it would - // change which input operand is tied to the destination. That would - // remove user control of the tail elements. - let isCommutable = 1, ForceTailAgnostic = true, VLMul = m.value in { - def "_VV_" # m.MX # "_COMMUTABLE" : VPseudoTernaryNoMask; - def "_VX_" # m.MX # "_COMMUTABLE" : - VPseudoTernaryNoMask; - } - } } multiclass VPseudoTernaryV_VV_VF_AAXA { defm "" : VPseudoTernaryV_VV; defm "" : VPseudoTernaryV_VF_AAXA; - - foreach m = MxList.m in { - // Add a commutable version for use by IR mul+add. - // NOTE: We need this because we use a tail undisturbed policy on the - // intrinsic version so we can't commute those instructions since it would - // change which input operand is tied to the destination. That would - // remove user control of the tail elements. - let isCommutable = 1, ForceTailAgnostic = true, VLMul = m.value in { - def "_VV_" # m.MX # "_COMMUTABLE" : VPseudoTernaryNoMask; - foreach f = FPList.fpinfo in - def "_V" # f.FX # "_" # m.MX # "_COMMUTABLE" : - VPseudoTernaryNoMask; - } - } } multiclass VPseudoTernaryV_VX_VI {