[clang] ecbf5db - [6/15][Clang][RISCV][NFC] Instructions with a mask destination register is always tail agnostic

via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 24 01:09:05 PST 2023


Author: eopXD
Date: 2023-01-24T01:08:58-08:00
New Revision: ecbf5db88d285f72fbd0126be9c20f790d603b23

URL: https://github.com/llvm/llvm-project/commit/ecbf5db88d285f72fbd0126be9c20f790d603b23
DIFF: https://github.com/llvm/llvm-project/commit/ecbf5db88d285f72fbd0126be9c20f790d603b23.diff

LOG: [6/15][Clang][RISCV][NFC] Instructions with a mask destination register is always tail agnostic

The logic under `computeBuiltinTypes` is an amendment 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.

This is the 6th commit of a patch-set that aims to change the default policy
for RVV intrinsics from TAMU to TAMA.

Please refer to the cover letter in the 1st commit (D141573) for an
overview.

Reviewed By: craig.topper, kito-cheng

Differential Revision: https://reviews.llvm.org/D141756

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index dc5323062ed4..e64bab60cad2 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -134,13 +134,9 @@ struct Policy {
     return TailPolicy == Undisturbed && MaskPolicy == Omit;
   }
 
-  bool isMAPolicy() const {
-    return MaskPolicy == Agnostic && TailPolicy == Omit;
-  }
+  bool isMAPolicy() const { return MaskPolicy == Agnostic; }
 
-  bool isMUPolicy() const {
-    return MaskPolicy == Undisturbed && TailPolicy == Omit;
-  }
+  bool isMUPolicy() const { return MaskPolicy == Undisturbed; }
 
   bool hasTailPolicy() const { return HasTailPolicy; }
 

diff  --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
index 280fd3f8669a..e93c5533d916 100644
--- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -915,9 +915,6 @@ llvm::SmallVector<PrototypeDescriptor> RVVIntrinsic::computeBuiltinTypes(
     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
@@ -998,10 +995,11 @@ RVVIntrinsic::getSupportedMaskedPolicies(bool HasTailPolicy,
             Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
                    HasTailPolicy, HasMaskPolicy)}; // TAM
   if (!HasTailPolicy && HasMaskPolicy)
-    return {Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic,
+    return {Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
                    HasTailPolicy, HasMaskPolicy), // MA
-            Policy(Policy::PolicyType::Omit, Policy::PolicyType::Undisturbed,
-                   HasTailPolicy, HasMaskPolicy)}; // MU
+            Policy(Policy::PolicyType::Agnostic,
+                   Policy::PolicyType::Undisturbed, HasTailPolicy,
+                   HasMaskPolicy)}; // MU
   llvm_unreachable("An RVV instruction should not be without both tail policy "
                    "and mask policy");
 }
@@ -1040,6 +1038,10 @@ void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, bool HasPolicy,
       appendPolicySuffix("_tum");
     else if (PolicyAttrs.isTAMAPolicy() && !PolicyAttrs.hasMaskPolicy())
       appendPolicySuffix("_tam");
+    else if (PolicyAttrs.isMUPolicy() && !PolicyAttrs.hasTailPolicy())
+      appendPolicySuffix("_mu");
+    else if (PolicyAttrs.isMAPolicy() && !PolicyAttrs.hasTailPolicy())
+      appendPolicySuffix("_ma");
     else if (PolicyAttrs.isTUMUPolicy())
       appendPolicySuffix("_tumu");
     else if (PolicyAttrs.isTAMUPolicy())
@@ -1052,13 +1054,7 @@ void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, bool HasPolicy,
       appendPolicySuffix("_tu");
     else if (PolicyAttrs.isTAPolicy() && !IsMasked)
       appendPolicySuffix("_ta");
-    else if (PolicyAttrs.isMUPolicy() && !PolicyAttrs.hasTailPolicy()) {
-      appendPolicySuffix("_mu");
-      PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-    } else if (PolicyAttrs.isMAPolicy() && !PolicyAttrs.hasTailPolicy()) {
-      appendPolicySuffix("_ma");
-      PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-    } else
+    else
       llvm_unreachable("Unhandled policy condition");
   }
 }


        


More information about the cfe-commits mailing list