1// RUN: %clang_cc1 %s -triple mips-unknown-linux-gnu -emit-llvm -o - | FileCheck %s
2//
3// Test that the ctlz and cttz builtins are defined for zero.
4// Based on count-builtin.c
5
6int leading, trailing, pop;
7
8void test_i16(short P) {
9  leading = __builtin_clzs(P);
10  trailing = __builtin_ctzs(P);
11
12// CHECK: @test_i16
13// CHECK: call i16 @llvm.ctlz.i16(i16 {{.*}}, i1 false)
14// CHECK: call i16 @llvm.cttz.i16(i16 {{.*}}, i1 false)
15}
16
17void test_i32(int P) {
18  leading = __builtin_clz(P);
19  trailing = __builtin_ctz(P);
20
21// CHECK: @test_i32
22// CHECK: call i32 @llvm.ctlz.i32(i32 {{.*}}, i1 false)
23// CHECK: call i32 @llvm.cttz.i32(i32 {{.*}}, i1 false)
24}
25
26void test_i64(float P) {
27  leading = __builtin_clzll(P);
28  trailing = __builtin_ctzll(P);
29// CHECK: @test_i64
30// CHECK: call i64 @llvm.ctlz.i64(i64 {{.*}}, i1 false)
31// CHECK: call i64 @llvm.cttz.i64(i64 {{.*}}, i1 false)
32}
33