[llvm] [VP] Refactor VectorBuilder to avoid layering violation. NFC (PR #99276)
Mel Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 24 03:06:48 PDT 2024
================
@@ -367,6 +367,59 @@ TEST_F(VPIntrinsicTest, IntrinsicIDRoundTrip) {
ASSERT_NE(FullTripCounts, 0u);
}
+/// Check that going from intrinsic to VP intrinsic and back results in the same
+/// intrinsic.
+TEST_F(VPIntrinsicTest, IntrinsicToVPRoundTrip) {
+ unsigned FullTripCounts = 0;
+ Intrinsic::ID IntrinsicID = Intrinsic::not_intrinsic + 1;
+ for (; IntrinsicID < Intrinsic::num_intrinsics; IntrinsicID++) {
+ Intrinsic::ID VPID = VPIntrinsic::getForIntrinsic(IntrinsicID);
+ // No equivalent VP intrinsic available.
+ if (VPID == Intrinsic::not_intrinsic)
+ continue;
+
+ // Return itself if passed intrinsic ID is VP intrinsic.
+ if (VPIntrinsic::isVPIntrinsic(IntrinsicID)) {
+ ASSERT_EQ(IntrinsicID, VPID);
+ continue;
+ }
+
+ std::optional<Intrinsic::ID> RoundTripIntrinsicID =
+ VPIntrinsic::getFunctionalIntrinsicIDForVP(VPID);
+ // No equivalent non-predicated intrinsic available.
+ if (!RoundTripIntrinsicID)
+ continue;
+
+ ASSERT_EQ(*RoundTripIntrinsicID, IntrinsicID);
+ ++FullTripCounts;
+ }
+ ASSERT_NE(FullTripCounts, 0u);
----------------
Mel-Chen wrote:
9f8748efca1708183f06bc469c03b6661f22c93e
There are two ways to improve this:
1. If we only need to check whether at least one full trip is completed, boolean is good enough.
2. Perform a detailed check of the number of full trips executed. Currently, there will be a total of 54 full trips.
For now, I will adopt the first way.
If it needs to be changed to the second way, I have a question: Is there a simple way, besides using
```#define VP_PROPERTY_FUNCTIONAL_INTRINSIC(INTRIN) FullTripCountsAns++;```, to obtain the total number of corresponding equivalent non-VP intrinsics in VPIntrinsic?
https://github.com/llvm/llvm-project/pull/99276
More information about the llvm-commits
mailing list