File tree Expand file tree Collapse file tree 4 files changed +12
-16
lines changed Expand file tree Collapse file tree 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 {
832832 def rdseed32_step : X86Builtin<" unsigned int(unsigned int *)" >;
833833}
834834
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-
840835let Features = " bmi" , Attributes = [NoThrow, Const, Constexpr] in {
841836 def bextr_u32 : X86Builtin<" unsigned int(unsigned int, unsigned int)" >;
842837}
843838
844839let Attributes = [NoThrow, Const, Constexpr] in {
845840 def tzcnt_u16 : X86Builtin<" unsigned short(unsigned short)" >;
846841 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)" >;
847844}
848845
849846let 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 {
126126 def rdseed64_step : X86Builtin<" unsigned int(unsigned long long int *)" >;
127127}
128128
129- let Features = " lzcnt" , Attributes = [NoThrow, Const, Constexpr] in {
130- def lzcnt_u64 : X86Builtin<" unsigned long long int(unsigned long long int)" >;
131- }
132-
133129let Features = " bmi" , Attributes = [NoThrow, Const, Constexpr] in {
134130 def bextr_u64 : X86Builtin<" unsigned long long int(unsigned long long int, unsigned long long int)" >;
135131}
136132
137133let Attributes = [NoThrow, Const, Constexpr] in {
138134 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)" >;
139136}
140137
141138let Features = " bmi2" , Attributes = [NoThrow, Const, Constexpr] in {
Original file line number Diff line number Diff line change 1414#ifndef __LZCNTINTRIN_H
1515#define __LZCNTINTRIN_H
1616
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. */
1821#if defined(__cplusplus) && (__cplusplus >= 201103L)
1922#define __DEFAULT_FN_ATTRS \
20- __attribute__ ((__always_inline__, __nodebug__, __target__( " lzcnt " ) )) constexpr
23+ __attribute__ ((__always_inline__, __nodebug__)) constexpr
2124#else
22- #define __DEFAULT_FN_ATTRS \
23- __attribute__ ((__always_inline__, __nodebug__, __target__(" lzcnt" )))
25+ #define __DEFAULT_FN_ATTRS __attribute__ ((__always_inline__, __nodebug__))
2426#endif
2527
2628#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
33
44
55#include <immintrin.h>
@@ -56,4 +56,4 @@ char lzcntu32_2[_lzcnt_u32(0x00000010) == 27 ? 1 : -1];
5656char lzcntu64_0 [_lzcnt_u64 (0x0000000000000000ULL ) == 64 ? 1 : -1 ];
5757char lzcntu64_1 [_lzcnt_u64 (0x8000000000000000ULL ) == 0 ? 1 : -1 ];
5858char lzcntu64_2 [_lzcnt_u64 (0x0000000100000000ULL ) == 31 ? 1 : -1 ];
59- #endif
59+ #endif
You can’t perform that action at this time.
0 commit comments