[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / builtin_clrsb.c
blobc51777ed1222ceebfa069865d245d6156973e3cf
1 // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
3 int test__builtin_clrsb(int x) {
4 // CHECK-LABEL: test__builtin_clrsb
5 // CHECK: [[C:%.*]] = icmp slt i32 [[X:%.*]], 0
6 // CHECK-NEXT: [[INV:%.*]] = xor i32 [[X]], -1
7 // CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i32 [[INV]], i32 [[X]]
8 // CHECK-NEXT: [[CTLZ:%.*]] = call i32 @llvm.ctlz.i32(i32 [[SEL]], i1 false)
9 // CHECK-NEXT: [[SUB:%.*]] = sub i32 [[CTLZ]], 1
10 return __builtin_clrsb(x);
13 int test__builtin_clrsbll(long long x) {
14 // CHECK-LABEL: test__builtin_clrsbll
15 // CHECK: [[C:%.*]] = icmp slt i64 [[X:%.*]], 0
16 // CHECK-NEXT: [[INV:%.*]] = xor i64 [[X]], -1
17 // CHECK-NEXT: [[SEL:%.*]] = select i1 [[C]], i64 [[INV]], i64 [[X]]
18 // CHECK-NEXT: [[CTLZ:%.*]] = call i64 @llvm.ctlz.i64(i64 [[SEL]], i1 false)
19 // CHECK-NEXT: [[SUB:%.*]] = sub i64 [[CTLZ]], 1
20 // CHECK-NEXT: trunc i64 [[SUB]] to i32
21 return __builtin_clrsbll(x);