brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 06c6994 Raw
68 lines · c
1// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-unknown -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s2// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-unknown-unknown -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s3 4// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-unknown -no-enable-noundef-analysis -emit-llvm -o - -fexperimental-new-constant-interpreter | FileCheck %s5// 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 %s6 7// PR337228// 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 %s9// 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 %s10 11 12#include <x86intrin.h>13#include "builtin_test_helpers.h"14 15int test_bit_scan_forward(int a) {16// CHECK-LABEL: test_bit_scan_forward17// CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)18// CHECK: ret i32 %[[call]]19  return _bit_scan_forward(a);20}21TEST_CONSTEXPR(_bit_scan_forward(0x00000001) ==  0);22TEST_CONSTEXPR(_bit_scan_forward(0x10000000) == 28);23 24int test_bit_scan_reverse(int a) {25// CHECK-LABEL: test_bit_scan_reverse26// CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)27// CHECK:  %[[sub:.*]] = sub nsw i32 31, %[[call]]28// CHECK: ret i32 %[[sub]]29  return _bit_scan_reverse(a);30}31TEST_CONSTEXPR(_bit_scan_reverse(0x00000001) ==  0);32TEST_CONSTEXPR(_bit_scan_reverse(0x01000000) == 24);33 34int test__bsfd(int X) {35// CHECK-LABEL: test__bsfd36// CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)37  return __bsfd(X);38}39TEST_CONSTEXPR(__bsfd(0x00000008) ==  3);40TEST_CONSTEXPR(__bsfd(0x00010008) ==  3);41 42int test__bsfq(long long X) {43// CHECK-LABEL: test__bsfq44// CHECK: %[[call:.*]] = call i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)45  return __bsfq(X);46}47TEST_CONSTEXPR(__bsfq(0x0000000800000000ULL) == 35);48TEST_CONSTEXPR(__bsfq(0x0004000000000000ULL) == 50);49 50int test__bsrd(int X) {51// CHECK-LABEL: test__bsrd52// CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)53// CHECK:  %[[sub:.*]] = sub nsw i32 31, %[[call]]54  return __bsrd(X);55}56TEST_CONSTEXPR(__bsrd(0x00000010) ==  4);57TEST_CONSTEXPR(__bsrd(0x00100100) == 20);58 59int test__bsrq(long long X) {60// CHECK-LABEL: test__bsrq61// CHECK:  %[[call:.*]] = call i64 @llvm.ctlz.i64(i64 %{{.*}}, i1 true)62// CHECK:  %[[cast:.*]] = trunc i64 %[[call]] to i3263// CHECK:  %[[sub:.*]] = sub nsw i32 63, %[[cast]]64  return __bsrq(X);65}66TEST_CONSTEXPR(__bsrq(0x0000100800000000ULL) == 44);67TEST_CONSTEXPR(__bsrq(0x0004000100000000ULL) == 50);68