Skip to content

[RISCV] Remove policy and merge operand from unmasked vmsbf/vmsif/vmsof.m. #94530

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

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Jun 5, 2024

These instructions always update the destination under a tail agnostic policy.

…of.m.

These instructions always update the destination under a tail agnostic policy.
@llvmbot
Copy link
Member

llvmbot commented Jun 5, 2024

@llvm/pr-subscribers-backend-risc-v

Author: Craig Topper (topperc)

Changes

These instructions always update the destination under a tail agnostic policy.


Full diff: https://github.com/llvm/llvm-project/pull/94530.diff

1 Files Affected:

  • (modified) llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td (+18-3)
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
index 5fe5a7a5bd5cc..5db7cb4dc6180 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
@@ -1033,6 +1033,22 @@ class VPseudoUnaryNoMask<DAGOperand RetClass,
   let HasVecPolicyOp = 1;
 }
 
+class VPseudoUnaryNoMaskNoPolicy<DAGOperand RetClass,
+                                 DAGOperand OpClass,
+                                 string Constraint = "",
+                                 int TargetConstraintType = 1> :
+      Pseudo<(outs RetClass:$rd),
+             (ins OpClass:$rs2, AVL:$vl, ixlenimm:$sew), []>,
+      RISCVVPseudo {
+  let mayLoad = 0;
+  let mayStore = 0;
+  let hasSideEffects = 0;
+  let Constraints = Constraint;
+  let TargetOverlapConstraintType = TargetConstraintType;
+  let HasVLOp = 1;
+  let HasSEWOp = 1;
+}
+
 class VPseudoUnaryNoMaskRoundingMode<DAGOperand RetClass,
                                      DAGOperand OpClass,
                                      string Constraint = "",
@@ -2056,7 +2072,7 @@ multiclass VPseudoVSFS_M {
   foreach mti = AllMasks in {
     defvar mx = mti.LMul.MX;
     let VLMul = mti.LMul.value in {
-      def "_M_" # mti.BX : VPseudoUnaryNoMask<VR, VR, constraint>,
+      def "_M_" # mti.BX : VPseudoUnaryNoMaskNoPolicy<VR, VR, constraint>,
                            SchedUnary<"WriteVMSFSV", "ReadVMSFSV", mx,
                                       forceMergeOpRead=true>;
       def "_M_" # mti.BX # "_MASK" : VPseudoUnaryMask<VR, VR, constraint>,
@@ -4078,9 +4094,8 @@ class VPatMaskUnaryNoMask<string intrinsic_name,
                 (mti.Mask VR:$rs2),
                 VLOpFrag)),
                 (!cast<Instruction>(inst#"_M_"#mti.BX)
-                (mti.Mask (IMPLICIT_DEF)),
                 (mti.Mask VR:$rs2),
-                GPR:$vl, mti.Log2SEW, TA_MA)>;
+                GPR:$vl, mti.Log2SEW)>;
 
 class VPatMaskUnaryMask<string intrinsic_name,
                         string inst,

@preames
Copy link
Collaborator

preames commented Jun 5, 2024

Why bother? Given we need the masked variants which do have a mask policy, what do we gain by having distinct pseudo shapes between unmasked and masked? Is the goal to exploit the don't care on the tail policy? If so, then why not do that directly so that the masked variants benefit as well?

@preames
Copy link
Collaborator

preames commented Jun 5, 2024

Why bother? Given we need the masked variants which do have a mask policy, what do we gain by having distinct pseudo shapes between unmasked and masked? Is the goal to exploit the don't care on the tail policy? If so, then why not do that directly so that the masked variants benefit as well?

On reflection, I realized we already have different shapes for these due to the mask operand. Ignore this please.

Copy link
Collaborator

@preames preames left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@topperc
Copy link
Collaborator Author

topperc commented Jun 5, 2024

Why bother? Given we need the masked variants which do have a mask policy, what do we gain by having distinct pseudo shapes between unmasked and masked? Is the goal to exploit the don't care on the tail policy? If so, then why not do that directly so that the masked variants benefit as well?

Goal was just to remove dimensions that should never be used. After the issue I found with reductions last week, I started auditing uses of TAIL_AGNOSTIC and TA_MA.

@topperc topperc merged commit c599894 into llvm:main Jun 5, 2024
7 of 8 checks passed
@topperc topperc deleted the pr/vms_f_unmasked branch June 5, 2024 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants