1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
5 // CHECK: [[NEG:%.*]] = sub nsw i32 0, [[X:%.*]]
6 // CHECK: [[CMP:%.*]] = icmp slt i32 [[X]], 0
7 // CHECK: [[SEL:%.*]] = select i1 [[CMP]], i32 [[NEG]], i32 [[X]]
9 return __builtin_abs(x
);
13 // CHECK-LABEL: @absl(
14 // CHECK: [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
15 // CHECK: [[CMP:%.*]] = icmp slt i64 [[X]], 0
16 // CHECK: [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
18 return __builtin_labs(x
);
21 long long absll(long long x
) {
22 // CHECK-LABEL: @absll(
23 // CHECK: [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
24 // CHECK: [[CMP:%.*]] = icmp slt i64 [[X]], 0
25 // CHECK: [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
27 return __builtin_llabs(x
);