summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-05-22 15:11:59 +0000
committerSanjay Patel <spatel@rotateright.com>2018-05-22 15:11:59 +0000
commitb6e5d4ead116a389e185cf0ee357d584933a15c4 (patch)
treee3880ad831470395c2f318b9b6ba2202cab50153
parent6dfcc78364fa3e8104d6e6634733863eb0bf4be8 (diff)
downloadbcm5719-llvm-b6e5d4ead116a389e185cf0ee357d584933a15c4.tar.gz
bcm5719-llvm-b6e5d4ead116a389e185cf0ee357d584933a15c4.zip
[CodeGen] add tests for abs builtins; NFC
llvm-svn: 332988
-rw-r--r--clang/test/CodeGen/builtin-abs.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/test/CodeGen/builtin-abs.c b/clang/test/CodeGen/builtin-abs.c
new file mode 100644
index 00000000000..b68d465d2f3
--- /dev/null
+++ b/clang/test/CodeGen/builtin-abs.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+int absi(int x) {
+// CHECK-LABEL: @absi(
+// CHECK: [[NEG:%.*]] = sub i32 0, [[X:%.*]]
+// CHECK: [[CMP:%.*]] = icmp sge i32 [[X]], 0
+// CHECK: [[SEL:%.*]] = select i1 [[CMP]], i32 [[X]], i32 [[NEG]]
+//
+ return __builtin_abs(x);
+}
+
+long absl(long x) {
+// CHECK-LABEL: @absl(
+// CHECK: [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK: [[CMP:%.*]] = icmp sge i64 [[X]], 0
+// CHECK: [[SEL:%.*]] = select i1 [[CMP]], i64 [[X]], i64 [[NEG]]
+//
+ return __builtin_labs(x);
+}
+
+long long absll(long long x) {
+// CHECK-LABEL: @absll(
+// CHECK: [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK: [[CMP:%.*]] = icmp sge i64 [[X]], 0
+// CHECK: [[SEL:%.*]] = select i1 [[CMP]], i64 [[X]], i64 [[NEG]]
+//
+ return __builtin_llabs(x);
+}
+
OpenPOWER on IntegriCloud