Skip to content

Conversation

@shri-acha
Copy link

Covers the test for AVX512 comparison intrinsics mentioned in:
#162054

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added clang Clang issues not falling into any other category backend:X86 labels Nov 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 25, 2025

@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-clang

Author: irhs0 (shri-acha)

Changes

Covers the test for AVX512 comparison intrinsics mentioned in:
#162054


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

1 Files Affected:

  • (modified) clang/test/CodeGen/X86/avx512vlbw-builtins.c (+112-9)
diff --git a/clang/test/CodeGen/X86/avx512vlbw-builtins.c b/clang/test/CodeGen/X86/avx512vlbw-builtins.c
index 16e113031bfda..cb69205664a3d 100644
--- a/clang/test/CodeGen/X86/avx512vlbw-builtins.c
+++ b/clang/test/CodeGen/X86/avx512vlbw-builtins.c
@@ -645,20 +645,123 @@ __mmask16 test_mm_cmp_epi8_mask(__m128i __a, __m128i __b) {
   return (__mmask16)_mm_cmp_epi8_mask(__a, __b, 0);
 }
 
+// cmpeq tests
 TEST_CONSTEXPR(_mm_cmpeq_epi8_mask(
-    ((__m128i)(__v16qi){5, 3, 7, 2, 9, 3, 7, 1, 5, 4, 8, 2, 9, 6, 7, 5}),
-    ((__m128i)(__v16qi){5, 2, 7, 3, 9, 4, 6, 1, 5, 3, 8, 1, 9, 5, 7, 5})
-) == (__mmask16)0xd595);
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}),
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
+) == (__mmask16)0xffff);
+
+TEST_CONSTEXPR(_mm_cmpeq_epi8_mask(
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}),
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
+) == (__mmask16)0xffff);
+
+TEST_CONSTEXPR(_mm_cmpeq_epi8_mask(
+    ((__m128i)(__v16qi){127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127}),
+    ((__m128i)(__v16qi){-128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128})
+) == (__mmask16)0x0000);
+
+TEST_CONSTEXPR(_mm_cmpeq_epi8_mask(
+    ((__m128i)(__v16qi){-31, 90, -66, 3, 27, -22, -64, 111, -87, 105, -19, 0, 26, -111, 24, -72}),
+    ((__m128i)(__v16qi){-84, -98, 20, -83, -98, 80, -46, -9, 22, -120, -123, 53, 117, -85, 50, 94})
+) == (__mmask16)0x0000);
+
+// cmpneq tests
+TEST_CONSTEXPR(_mm_cmpneq_epi8_mask(
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}),
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
+) == (__mmask16)0x0000);
+
+TEST_CONSTEXPR(_mm_cmpneq_epi8_mask(
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}),
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
+) == (__mmask16)0x0000);
+
+TEST_CONSTEXPR(_mm_cmpneq_epi8_mask(
+    ((__m128i)(__v16qi){127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127}),
+    ((__m128i)(__v16qi){-128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128})
+) == (__mmask16)0xffff);
+
+TEST_CONSTEXPR(_mm_cmpneq_epi8_mask(
+    ((__m128i)(__v16qi){-2, 49, -5, -11, 21, -70, 121, -111, 20, 112, -121, 18, -34, -73, 89, 122}),
+    ((__m128i)(__v16qi){14, 36, 2, 3, 118, 88, -126, -21, 104, -125, -1, 39, 99, -12, 35, -126})
+) == (__mmask16)0xffff);
+
+// cmplt tests
+TEST_CONSTEXPR(_mm_cmplt_epi8_mask(
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}),
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
+) == (__mmask16)0x0000);
 
 TEST_CONSTEXPR(_mm_cmplt_epi8_mask(
-    ((__m128i)(__v16qi){1, 5, 3, 7, 2, 8, 4, 6, 9, 5, 3, 11, 2, 6, 15, 8}),
-    ((__m128i)(__v16qi){2, 4, 6, 8, 3, 5, 7, 9, 4, 6, 8, 10, 5, 7, 9, 11})
-) == (__mmask16)0xb6dd);
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}),
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
+) == (__mmask16)0x0000);
 
+TEST_CONSTEXPR(_mm_cmplt_epi8_mask(
+    ((__m128i)(__v16qi){127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127}),
+    ((__m128i)(__v16qi){-128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128})
+) == (__mmask16)0x0000);
+
+TEST_CONSTEXPR(_mm_cmplt_epi8_mask(
+    ((__m128i)(__v16qi){-111, -10, -60, -123, -6, -110, -43, -32, -58, -7, 42, -128, -21, 24, 8, -101}),
+    ((__m128i)(__v16qi){-108, 30, 71, 73, 20, 117, 63, -93, 79, -30, 99, -100, 34, 49, 83, 68})
+) == (__mmask16)0xfd7f);
+
+// cmple tests
+TEST_CONSTEXPR(_mm_cmple_epi8_mask(
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}),
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
+) == (__mmask16)0xffff);
 TEST_CONSTEXPR(_mm_cmple_epi8_mask(
-    ((__m128i)(__v16qi){1, 3, 5, 7, 2, 6, 6, 8, 1, 3, 9, 7, 2, 4, 6, 10}),
-    ((__m128i)(__v16qi){2, 3, 4, 7, 3, 4, 5, 8, 2, 3, 4, 7, 3, 4, 5, 8})
-) == (__mmask16)0x3b9b);
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}),
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
+) == (__mmask16)0xffff);
+TEST_CONSTEXPR(_mm_cmple_epi8_mask(
+    ((__m128i)(__v16qi){127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127}),
+    ((__m128i)(__v16qi){-128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128})
+) == (__mmask16)0x0000);
+TEST_CONSTEXPR(_mm_cmple_epi8_mask(
+    ((__m128i)(__v16qi){122, 6, -22, -94, 78, -35, -43, -16, -69, 124, -2, 24, -117, 8, -17, 118}),
+    ((__m128i)(__v16qi){53, -50, 104, 11, 63, -77, -25, 102, 46, 62, 27, -28, -61, 68, 40, -65})
+) == (__mmask16)0x75cc);
+
+// cmpge tests
+TEST_CONSTEXPR(_mm_cmpge_epi8_mask(
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}),
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
+) == (__mmask16)0xffff);
+TEST_CONSTEXPR(_mm_cmpge_epi8_mask(
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}),
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
+) == (__mmask16)0xffff);
+TEST_CONSTEXPR(_mm_cmpge_epi8_mask(
+    ((__m128i)(__v16qi){127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127}),
+    ((__m128i)(__v16qi){-128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128})
+) == (__mmask16)0xffff);
+TEST_CONSTEXPR(_mm_cmpge_epi8_mask(
+    ((__m128i)(__v16qi){-11, 0, 97, 123, -48, 105, 26, -118, 62, -86, -94, -32, 14, -4, -50, 72}),
+    ((__m128i)(__v16qi){-33, 49, 22, 31, -4, -81, 6, -22, 40, 127, -1, -106, 6, -64, 12, 8})
+) == (__mmask16)0xb96d);
+
+// cmpgt tests
+TEST_CONSTEXPR(_mm_cmpgt_epi8_mask(
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}),
+    ((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
+) == (__mmask16)0x0000);
+TEST_CONSTEXPR(_mm_cmpgt_epi8_mask(
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}),
+    ((__m128i)(__v16qi){1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})
+) == (__mmask16)0x0000);
+TEST_CONSTEXPR(_mm_cmpgt_epi8_mask(
+    ((__m128i)(__v16qi){127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127}),
+    ((__m128i)(__v16qi){-128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128})
+) == (__mmask16)0xffff);
+TEST_CONSTEXPR(_mm_cmpgt_epi8_mask(
+    ((__m128i)(__v16qi){-127, 37, -123, -60, 98, -68, -115, 96, 80, -27, -105, 64, -6, -51, -45, -81}),
+    ((__m128i)(__v16qi){-124, 59, 8, 59, 122, 47, -74, 120, 19, -43, -33, -76, 7, -22, -24, -14})
+) == (__mmask16)0x0b00);
+
 
 __mmask16 test_mm_mask_cmp_epi8_mask(__mmask16 __u, __m128i __a, __m128i __b) {
   // CHECK-LABEL: test_mm_mask_cmp_epi8_mask

@shri-acha shri-acha marked this pull request as draft November 25, 2025 04:41
@shri-acha
Copy link
Author

@RKSimon could you verify the nature of the tests?, after i'll add the other generated tests from the script

@RKSimon RKSimon self-requested a review November 25, 2025 09:49
@github-actions
Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

) == (__mmask16)0xd595);
((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}),
((__m128i)(__v16qi){0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})
) == (__mmask16)0xffff);
Copy link
Collaborator

Choose a reason for hiding this comment

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

avoid 'splat' tests like this - all ones/zero results always make me suspicious :)

Copy link
Author

@shri-acha shri-acha Nov 25, 2025

Choose a reason for hiding this comment

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

:) okay ,will modify the 'splat' cases here onwards.

((__m128i)(__v16qi){-31, 90, -66, 3, 27, -22, -64, 111, -87, 105, -19, 0, 26, -111, 24, -72}),
((__m128i)(__v16qi){-84, -98, 20, -83, -98, 80, -46, -9, 22, -120, -123, 53, 117, -85, 50, 94})
) == (__mmask16)0x0000);

Copy link
Collaborator

Choose a reason for hiding this comment

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

You need _mm_mask_cmpeq_epi8_mask (et al) test coverage as well

Copy link
Author

@shri-acha shri-acha Nov 25, 2025

Choose a reason for hiding this comment

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

yes, I do have those in mind aswell, i will cover those after all of the _mm_mask_cmp*_epi* are complete.

@github-actions
Copy link

github-actions bot commented Nov 25, 2025

🐧 Linux x64 Test Results

  • 84778 tests passed
  • 1116 tests skipped
  • 1 test failed

Failed tests and their output was too large to report. Download the build's log file to see the details.

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@shri-acha shri-acha marked this pull request as ready for review November 28, 2025 03:04
@shri-acha
Copy link
Author

@RKSimon I'm unsure why the tests are failing for _mm_cmp*_epu16_mask, am I missing something?

@RKSimon RKSimon self-requested a review November 28, 2025 08:49
@RKSimon
Copy link
Collaborator

RKSimon commented Nov 28, 2025

@RKSimon I'm unsure why the tests are failing for _mm_cmp*_epu16_mask, am I missing something?

Try after #169891


TEST_CONSTEXPR(_mm_cmpeq_epi8_mask(
((__m128i)(__v16qi){127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127}),
((__m128i)(__v16qi){-128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, -128})
Copy link
Collaborator

Choose a reason for hiding this comment

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

you have to use __v16qs / __v32qs / __v64qs to allow you to use signed chars

Copy link
Author

Choose a reason for hiding this comment

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

__vqs in epi variants and __vqi for epu variants then?

Copy link
Collaborator

Choose a reason for hiding this comment

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

vXqu for unsigned char

@RKSimon RKSimon self-requested a review November 30, 2025 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:X86 clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants