| 1 | // RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s |
| 2 | |
| 3 | // PR33722 |
| 4 | // RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown -fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - %s | FileCheck %s |
| 5 | |
| 6 | #include <x86intrin.h> |
| 7 | |
| 8 | int test_bit_scan_forward(int a) { |
| 9 | return _bit_scan_forward(a); |
| 10 | // CHECK: @test_bit_scan_forward |
| 11 | // CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true) |
| 12 | // CHECK: ret i32 %[[call]] |
| 13 | } |
| 14 | |
| 15 | int test_bit_scan_reverse(int a) { |
| 16 | return _bit_scan_reverse(a); |
| 17 | // CHECK: %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true) |
| 18 | // CHECK: %[[sub:.*]] = sub nsw i32 31, %[[call]] |
| 19 | // CHECK: ret i32 %[[sub]] |
| 20 | } |
| 21 | |
| 22 | int test__bsfd(int X) { |
| 23 | // CHECK: @test__bsfd |
| 24 | // CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true) |
| 25 | return __bsfd(X); |
| 26 | } |
| 27 | |
| 28 | int test__bsfq(long long X) { |
| 29 | // CHECK: @test__bsfq |
| 30 | // CHECK: %[[call:.*]] = call i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true) |
| 31 | return __bsfq(X); |
| 32 | } |
| 33 | |
| 34 | int test__bsrd(int X) { |
| 35 | // CHECK: @test__bsrd |
| 36 | // CHECK: %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true) |
| 37 | // CHECK: %[[sub:.*]] = sub nsw i32 31, %[[call]] |
| 38 | return __bsrd(X); |
| 39 | } |
| 40 | |
| 41 | int test__bsrq(long long X) { |
| 42 | // CHECK: @test__bsrq |
| 43 | // CHECK: %[[call:.*]] = call i64 @llvm.ctlz.i64(i64 %{{.*}}, i1 true) |
| 44 | // CHECK: %[[cast:.*]] = trunc i64 %[[call]] to i32 |
| 45 | // CHECK: %[[sub:.*]] = sub nsw i32 63, %[[cast]] |
| 46 | return __bsrq(X); |
| 47 | } |
| 48 | |