File tree 4 files changed +12
-16
lines changed 4 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -832,18 +832,15 @@ let Features = "rdseed", Attributes = [NoThrow] in {
832
832
def rdseed32_step : X86Builtin<" unsigned int(unsigned int *)" >;
833
833
}
834
834
835
- let Features = " lzcnt" , Attributes = [NoThrow, Const, Constexpr] in {
836
- def lzcnt_u16 : X86Builtin<" unsigned short(unsigned short)" >;
837
- def lzcnt_u32 : X86Builtin<" unsigned int(unsigned int)" >;
838
- }
839
-
840
835
let Features = " bmi" , Attributes = [NoThrow, Const, Constexpr] in {
841
836
def bextr_u32 : X86Builtin<" unsigned int(unsigned int, unsigned int)" >;
842
837
}
843
838
844
839
let Attributes = [NoThrow, Const, Constexpr] in {
845
840
def tzcnt_u16 : X86Builtin<" unsigned short(unsigned short)" >;
846
841
def tzcnt_u32 : X86Builtin<" unsigned int(unsigned int)" >;
842
+ def lzcnt_u16 : X86Builtin<" unsigned short(unsigned short)" >;
843
+ def lzcnt_u32 : X86Builtin<" unsigned int(unsigned int)" >;
847
844
}
848
845
849
846
let Features = " bmi2" , Attributes = [NoThrow, Const, Constexpr] in {
Original file line number Diff line number Diff line change @@ -126,16 +126,13 @@ let Features = "rdseed", Attributes = [NoThrow] in {
126
126
def rdseed64_step : X86Builtin<" unsigned int(unsigned long long int *)" >;
127
127
}
128
128
129
- let Features = " lzcnt" , Attributes = [NoThrow, Const, Constexpr] in {
130
- def lzcnt_u64 : X86Builtin<" unsigned long long int(unsigned long long int)" >;
131
- }
132
-
133
129
let Features = " bmi" , Attributes = [NoThrow, Const, Constexpr] in {
134
130
def bextr_u64 : X86Builtin<" unsigned long long int(unsigned long long int, unsigned long long int)" >;
135
131
}
136
132
137
133
let Attributes = [NoThrow, Const, Constexpr] in {
138
134
def tzcnt_u64 : X86Builtin<" unsigned long long int(unsigned long long int)" >;
135
+ def lzcnt_u64 : X86Builtin<" unsigned long long int(unsigned long long int)" >;
139
136
}
140
137
141
138
let Features = " bmi2" , Attributes = [NoThrow, Const, Constexpr] in {
Original file line number Diff line number Diff line change 14
14
#ifndef __LZCNTINTRIN_H
15
15
#define __LZCNTINTRIN_H
16
16
17
- /* Define the default attributes for the functions in this file. */
17
+ /* Define the default attributes for the functions in this file.
18
+ Allow using the lzcnt intrinsics even for non-LZCNT targets. Since the LZCNT
19
+ intrinsics are mapped to llvm.ctlz.*, false, which can be lowered to BSR on
20
+ non-LZCNT targets with zero-value input handled correctly. */
18
21
#if defined(__cplusplus) && (__cplusplus >= 201103L)
19
22
#define __DEFAULT_FN_ATTRS \
20
- __attribute__ ((__always_inline__, __nodebug__, __target__( " lzcnt " ) )) constexpr
23
+ __attribute__ ((__always_inline__, __nodebug__)) constexpr
21
24
#else
22
- #define __DEFAULT_FN_ATTRS \
23
- __attribute__ ((__always_inline__, __nodebug__, __target__(" lzcnt" )))
25
+ #define __DEFAULT_FN_ATTRS __attribute__ ((__always_inline__, __nodebug__))
24
26
#endif
25
27
26
28
#ifndef _MSC_VER
Original file line number Diff line number Diff line change 1
- // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +lzcnt - emit-llvm -o - | FileCheck %s
2
- // RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +lzcnt - emit-llvm -o - | FileCheck %s
1
+ // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
2
+ // RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
3
3
4
4
5
5
#include <immintrin.h>
@@ -56,4 +56,4 @@ char lzcntu32_2[_lzcnt_u32(0x00000010) == 27 ? 1 : -1];
56
56
char lzcntu64_0 [_lzcnt_u64 (0x0000000000000000ULL ) == 64 ? 1 : -1 ];
57
57
char lzcntu64_1 [_lzcnt_u64 (0x8000000000000000ULL ) == 0 ? 1 : -1 ];
58
58
char lzcntu64_2 [_lzcnt_u64 (0x0000000100000000ULL ) == 31 ? 1 : -1 ];
59
- #endif
59
+ #endif
You can’t perform that action at this time.
0 commit comments