[clang] [X86] Add -fexperimental-new-constant-interpreter test coverage to the BITSCAN constexpr test files (PR #156070)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 29 10:36:10 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Simon Pilgrim (RKSimon)
<details>
<summary>Changes</summary>
Update tests to use builtin_test_helpers.h and the TEST_CONSTEXPR helper macro
Partial fix for #<!-- -->155814
---
Full diff: https://github.com/llvm/llvm-project/pull/156070.diff
1 Files Affected:
- (modified) clang/test/CodeGen/X86/bitscan-builtins.c (+17-23)
``````````diff
diff --git a/clang/test/CodeGen/X86/bitscan-builtins.c b/clang/test/CodeGen/X86/bitscan-builtins.c
index 9fd4666417851..06c69945d2e56 100644
--- a/clang/test/CodeGen/X86/bitscan-builtins.c
+++ b/clang/test/CodeGen/X86/bitscan-builtins.c
@@ -1,11 +1,16 @@
// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-unknown -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-unknown-unknown -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-unknown -no-enable-noundef-analysis -emit-llvm -o - -fexperimental-new-constant-interpreter | FileCheck %s
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-unknown-unknown -no-enable-noundef-analysis -emit-llvm -o - -fexperimental-new-constant-interpreter | FileCheck %s
+
// PR33722
// RUN: %clang_cc1 -x c -ffreestanding %s -triple x86_64-unknown-unknown -fms-extensions -fms-compatibility-version=19.00 -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple x86_64-unknown-unknown -fms-extensions -fms-compatibility-version=19.00 -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s
+
#include <x86intrin.h>
+#include "builtin_test_helpers.h"
int test_bit_scan_forward(int a) {
// CHECK-LABEL: test_bit_scan_forward
@@ -13,6 +18,8 @@ int test_bit_scan_forward(int a) {
// CHECK: ret i32 %[[call]]
return _bit_scan_forward(a);
}
+TEST_CONSTEXPR(_bit_scan_forward(0x00000001) == 0);
+TEST_CONSTEXPR(_bit_scan_forward(0x10000000) == 28);
int test_bit_scan_reverse(int a) {
// CHECK-LABEL: test_bit_scan_reverse
@@ -21,18 +28,24 @@ int test_bit_scan_reverse(int a) {
// CHECK: ret i32 %[[sub]]
return _bit_scan_reverse(a);
}
+TEST_CONSTEXPR(_bit_scan_reverse(0x00000001) == 0);
+TEST_CONSTEXPR(_bit_scan_reverse(0x01000000) == 24);
int test__bsfd(int X) {
// CHECK-LABEL: test__bsfd
// CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
return __bsfd(X);
}
+TEST_CONSTEXPR(__bsfd(0x00000008) == 3);
+TEST_CONSTEXPR(__bsfd(0x00010008) == 3);
int test__bsfq(long long X) {
// CHECK-LABEL: test__bsfq
// CHECK: %[[call:.*]] = call i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)
return __bsfq(X);
}
+TEST_CONSTEXPR(__bsfq(0x0000000800000000ULL) == 35);
+TEST_CONSTEXPR(__bsfq(0x0004000000000000ULL) == 50);
int test__bsrd(int X) {
// CHECK-LABEL: test__bsrd
@@ -40,6 +53,8 @@ int test__bsrd(int X) {
// CHECK: %[[sub:.*]] = sub nsw i32 31, %[[call]]
return __bsrd(X);
}
+TEST_CONSTEXPR(__bsrd(0x00000010) == 4);
+TEST_CONSTEXPR(__bsrd(0x00100100) == 20);
int test__bsrq(long long X) {
// CHECK-LABEL: test__bsrq
@@ -48,26 +63,5 @@ int test__bsrq(long long X) {
// CHECK: %[[sub:.*]] = sub nsw i32 63, %[[cast]]
return __bsrq(X);
}
-
-// Test constexpr handling.
-#if defined(__cplusplus) && (__cplusplus >= 201103L)
-
-char bsf_0[_bit_scan_forward(0x00000001) == 0 ? 1 : -1];
-char bsf_1[_bit_scan_forward(0x10000000) == 28 ? 1 : -1];
-
-char bsr_0[_bit_scan_reverse(0x00000001) == 0 ? 1 : -1];
-char bsr_1[_bit_scan_reverse(0x01000000) == 24 ? 1 : -1];
-
-char bsfd_0[__bsfd(0x00000008) == 3 ? 1 : -1];
-char bsfd_1[__bsfd(0x00010008) == 3 ? 1 : -1];
-
-char bsrd_0[__bsrd(0x00000010) == 4 ? 1 : -1];
-char bsrd_1[__bsrd(0x00100100) == 20 ? 1 : -1];
-
-char bsfq_0[__bsfq(0x0000000800000000ULL) == 35 ? 1 : -1];
-char bsfq_1[__bsfq(0x0004000000000000ULL) == 50 ? 1 : -1];
-
-char bsrq_0[__bsrq(0x0000100800000000ULL) == 44 ? 1 : -1];
-char bsrq_1[__bsrq(0x0004000100000000ULL) == 50 ? 1 : -1];
-
-#endif
+TEST_CONSTEXPR(__bsrq(0x0000100800000000ULL) == 44);
+TEST_CONSTEXPR(__bsrq(0x0004000100000000ULL) == 50);
``````````
</details>
https://github.com/llvm/llvm-project/pull/156070
More information about the cfe-commits
mailing list