[PATCH] D141756: [WIP][6/N][Clang][RISCV][NFC] Instructions with a mask destination register is always tail agnostic

Yueh-Ting (eop) Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 14 04:41:59 PST 2023


eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

The logic under `computeBuiltinTypes` and `updateNamesAndPolicy` is an
amendmendment to setting Policy as `Omit`. The tail policy should be
set to agnostic for those intrinsics that has `HasTailPolicy = false`,
which are the intrinsics with a mask destination register.

Depends on D141754 <https://reviews.llvm.org/D141754>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141756

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===================================================================
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,6 @@
     PolicyScheme DefaultScheme, Policy PolicyAttrs) {
   SmallVector<PrototypeDescriptor> NewPrototype(Prototype.begin(),
                                                 Prototype.end());
-  // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
-  if (PolicyAttrs.isMAPolicy())
-    PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
     // If HasMaskedOffOperand, insert result type as first input operand if
@@ -1002,8 +999,8 @@
                    Policy::PolicyType::Agnostic)}; // TAM
   if (!HasTailPolicy && HasMaskPolicy)
     return {
-        Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-        Policy(Policy::PolicyType::Omit,
+        Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic), // MA
+        Policy(Policy::PolicyType::Agnostic,
                Policy::PolicyType::Undisturbed)}; // MU
   llvm_unreachable("An RVV instruction should not be without both tail policy "
                    "and mask policy");
@@ -1042,6 +1039,10 @@
       appendPolicySuffix("_tum");
     else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
       appendPolicySuffix("_tam");
+    else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
+      appendPolicySuffix("_mu");
+    else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
+      appendPolicySuffix("_ma");
     else if (PolicyAttrs.isTUMUPolicy())
       appendPolicySuffix("_tumu");
     else if (PolicyAttrs.isTAMUPolicy())
@@ -1054,13 +1055,7 @@
       appendPolicySuffix("_tu");
     else if (PolicyAttrs.isTAPolicy() && !IsMasked)
       appendPolicySuffix("_ta");
-    else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy) {
-      appendPolicySuffix("_mu");
-      PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-    } else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy) {
-      appendPolicySuffix("_ma");
-      PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-    } else
+    else
       llvm_unreachable("Unhandled policy condition");
   }
 }
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===================================================================
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -130,11 +130,11 @@
   }
 
   bool isMAPolicy() const {
-    return MaskPolicy == Agnostic && TailPolicy == Omit;
+    return MaskPolicy == Agnostic;
   }
 
   bool isMUPolicy() const {
-    return MaskPolicy == Undisturbed && TailPolicy == Omit;
+    return MaskPolicy == Undisturbed;
   }
 
   bool isUnspecified() const { return IsUnspecified; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141756.489227.patch
Type: text/x-patch
Size: 2916 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230114/8439f7ed/attachment.bin>


More information about the cfe-commits mailing list